fixed a segfault error in Awk.cpp for missed rtx->_instsize adjustment

This commit is contained in:
hyung-hwan 2019-09-03 16:46:57 +00:00
parent 8c6a7ae29c
commit f89efc150a
6 changed files with 19 additions and 26 deletions

View File

@ -1391,9 +1391,6 @@ int Awk::open ()
#endif
// push the call back after everything else is ok.
// the uponDemise() is called only if Awk::open() is fully successful.
// it won't be called when qse_awk_close() is called for functionMap
// opening failure above.
qse_awk_pushecb (this->awk, &xtn->ecb);
return 0;
}
@ -1464,7 +1461,7 @@ Awk::Run* Awk::parse (Source& in, Source& out)
return QSE_NULL;
}
if (init_runctx() <= -1) return QSE_NULL;
if (this->init_runctx() <= -1) return QSE_NULL;
return &this->runctx;
}
@ -1602,6 +1599,7 @@ int Awk::init_runctx ()
return -1;
}
rtx->_instsize += QSE_SIZEOF(rxtn_t);
runctx.rtx = rtx;
rxtn_t* rxtn = GET_RXTN(rtx);

View File

@ -203,15 +203,12 @@ StdAwk::Run* StdAwk::parse (Source& in, Source& out)
// but if you call parse() multiple times while
// setting and unsetting QSE_AWK_RIO in-between,
// cmgrtab can still be initialized when QSE_AWK_RIO is not set.
if (qse_htb_init (
&this->cmgrtab, this->getMmgr(), 256, 70,
QSE_SIZEOF(qse_char_t), 1) <= -1)
if (qse_htb_init(&this->cmgrtab, this->getMmgr(), 256, 70, QSE_SIZEOF(qse_char_t), 1) <= -1)
{
this->setError (QSE_AWK_ENOMEM);
return QSE_NULL;
}
qse_htb_setstyle (&this->cmgrtab,
qse_gethtbstyle(QSE_HTB_STYLE_INLINE_KEY_COPIER));
qse_htb_setstyle (&this->cmgrtab, qse_gethtbstyle(QSE_HTB_STYLE_INLINE_KEY_COPIER));
this->cmgrtab_inited = true;
}

View File

@ -1218,8 +1218,7 @@ static int prepare_globals (qse_awk_rtx_t* rtx)
}
/* override NF to zero */
if (qse_awk_rtx_setgbl (
rtx, QSE_AWK_GBL_NF, QSE_AWK_VAL_ZERO) <= -1) goto oops;
if (qse_awk_rtx_setgbl(rtx, QSE_AWK_GBL_NF, QSE_AWK_VAL_ZERO) <= -1) goto oops;
/* return success */
return 0;

View File

@ -1990,8 +1990,7 @@ static int build_argcv (
return 0;
}
static int __build_environ (
qse_awk_rtx_t* rtx, int gbl_id, qse_env_char_t* envarr[])
static int __build_environ (qse_awk_rtx_t* rtx, int gbl_id, qse_env_char_t* envarr[])
{
qse_awk_val_t* v_env;
qse_awk_val_t* v_tmp;

View File

@ -56,12 +56,12 @@ void* Mmgr::callocate (qse_size_t n, bool raise_exception) /*QSE_CPP_THREXCEPT1(
#if 0
#if defined(__GNUC__)
static StdMmgr __attribute__((init_priority(101))) std_dfl_mmgr; <- this solved the problem
static StdMmgr __attribute__((init_priority(101))) std_dfl_mmgr; //<- this solved the problem
#else
static StdMmgr std_dfl_mmgr; <-- has an issue for undefined initialization order
static StdMmgr std_dfl_mmgr; //<-- has an issue for undefined initialization order
#endif
Mmgr* Mmgr::dfl_mmgr = &std_dfl_mmgr;
//Mmgr* Mmgr::dfl_mmgr = StdMmgr::getInstance(); <--- has an issue as well
//Mmgr* Mmgr::dfl_mmgr = StdMmgr::getInstance(); //<--- has an issue as well
Mmgr* Mmgr::getDFL () QSE_CPP_NOEXCEPT
{
return Mmgr::dfl_mmgr;