explicitly clear instance flag bits when allocating new instance array data to avoid random data in bit 8 (IGNORE_INST). This does not cause any problem but random data in log files, causing false positives in automated regression tests

This commit is contained in:
stefan schippers 2023-07-07 23:54:46 +02:00
parent 83071b4b21
commit b646a0f79f
2 changed files with 6 additions and 0 deletions

View File

@ -750,6 +750,7 @@ int set_inst_flags(xInstance *inst)
const char *ptr;
inst->flags &= IGNORE_INST; /* do not clear IGNORE_INST bit, used in draw_symbol() */
my_strdup2(_ALLOC_ID_, &inst->instname, get_tok_value(inst->prop_ptr, "name", 0));
dbg(1, "set_inst_flags(): instname=%s\n", inst->instname);
if(inst->ptr >=0) {
char *type = xctx->sym[inst->ptr].type;
int cond= type && IS_LABEL_SH_OR_PIN(type);

View File

@ -68,11 +68,16 @@ void check_inst_storage(void)
{
if(xctx->instances >= xctx->maxi)
{
int i, old = xctx->maxi;
xctx->maxi=(1 + xctx->instances / ELEMINST) * ELEMINST;
my_realloc(_ALLOC_ID_, &xctx->inst, sizeof(xInstance)*xctx->maxi);
#ifdef ZERO_REALLOC
memset(xctx->inst + xctx->instances, 0, sizeof(xInstance) * (xctx->maxi - xctx->instances));
#endif
/* clear all flag bits (to avoid random data in bit 8, that can not be cleraed
* by set_inst_flags() */
for(i = old; i < xctx->maxi; i++) xctx->inst[i].flags = 0;
}
}