diff --git a/src/decode.c b/src/decode.c index c4656d56f9..42248556e7 100644 --- a/src/decode.c +++ b/src/decode.c @@ -2611,7 +2611,8 @@ secondheader_private (Bit_Chain *restrict dat, Dwg_Data *restrict dwg) { Bit_Chain *str_dat = dat; Dwg_SecondHeader *_obj = &dwg->secondheader; - Dwg_Object *obj = NULL; + // for error logging only: + Dwg_Object *obj = &(Dwg_Object){ .name = (char*)"2NDHEADER" }; int error = 0; BITCODE_BL vcount; if (!dat->chain || !dat->size) diff --git a/src/encode.c b/src/encode.c index fb263791d7..cdff6291f2 100644 --- a/src/encode.c +++ b/src/encode.c @@ -2353,7 +2353,8 @@ encode_secondheader_private (Bit_Chain *restrict dat, Dwg_Data *restrict dwg) { Bit_Chain *str_dat = dat; Dwg_SecondHeader *_obj = &dwg->secondheader; - Dwg_Object *obj = NULL; + // for error logging only: + Dwg_Object *obj = &(Dwg_Object){ .name = (char*)"2NDHEADER" }; int error = 0; BITCODE_BL vcount; if (!dat->chain || !dat->size) diff --git a/src/spec.h b/src/spec.h index e3328246e8..34d27c84cc 100644 --- a/src/spec.h +++ b/src/spec.h @@ -76,7 +76,7 @@ # define VALUEOUTOFBOUNDS(field, maxvalue) \ if (_IN_RANGE (_obj->field, maxvalue) && _obj->field > maxvalue) \ { \ - LOG_ERROR ("Invalid %s." #field " %lu", obj->name, \ + LOG_ERROR ("Invalid %s." #field " %lu", obj ? obj->name : "", \ (unsigned long)_obj->field); \ _obj->field = 0; \ return DWG_ERR_VALUEOUTOFBOUNDS; \ @@ -84,7 +84,7 @@ # define SUB_VALUEOUTOFBOUNDS(o, field, maxvalue) \ if (_IN_RANGE (_obj->o.field, maxvalue) && _obj->o.field > maxvalue) \ { \ - LOG_ERROR ("Invalid %s." #field " %lu", obj->name, \ + LOG_ERROR ("Invalid %s." #field " %lu", obj ? obj->name : "", \ (unsigned long)_obj->o.field); \ _obj->o.field = 0; \ return DWG_ERR_VALUEOUTOFBOUNDS; \