fixed a simple but critical bug in __MAKE_IMAP_NODE

This commit is contained in:
2019-08-26 10:29:26 +00:00
parent 4e6015ed36
commit d0d2a7af8c
4 changed files with 60 additions and 9 deletions

View File

@ -61,16 +61,16 @@ static __IMAP_NODE_T* __MAKE_IMAP_NODE (qse_awk_rtx_t* rtx, __IMAP_LIST_T* list)
node = QSE_NULL;
if (list->free) node = list->free;
if (list->free)
{
node = list->free;
list->free = node->next;
}
else
{
node = qse_awk_rtx_callocmem(rtx, QSE_SIZEOF(*node));
if (!node) goto oops;
}
if (node == list->free) list->free = node->next;
else
{
if (list->map.high <= list->map.capa)
{
qse_size_t newcapa, inc;
@ -92,11 +92,12 @@ static __IMAP_NODE_T* __MAKE_IMAP_NODE (qse_awk_rtx_t* rtx, __IMAP_LIST_T* list)
}
node->id = list->map.high;
QSE_ASSERT (list->map.tab[node->id] == QSE_NULL);
list->map.tab[node->id] = node;
list->map.high++;
}
QSE_ASSERT (list->map.tab[node->id] == QSE_NULL);
list->map.tab[node->id] = node;
/* append it to the tail */
node->next = QSE_NULL;
node->prev = list->tail;

View File

@ -30,6 +30,7 @@
#include <qse/cmn/mbwc.h>
#include "../cmn/mem-prv.h"
#include "fnc.h"
#include "val.h"
static int fnc_normspace (qse_awk_rtx_t* rtx, const qse_awk_fnc_info_t* fi)
{

View File

@ -484,7 +484,7 @@ static int fnc_openfd (qse_awk_rtx_t* rtx, const qse_awk_fnc_info_t* fi)
rx = awkerr_to_rc(qse_awk_rtx_geterrnum(rtx));
set_errmsg_on_sys_list (rtx, sys_list, QSE_NULL);
}
else if (fd >= 0)
else if (fd >= 0 && fd <= QSE_TYPE_MAX(int))
{
sys_node_t* sys_node;