Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing NULL check #173

Closed
ManSoSec opened this issue Dec 11, 2019 · 0 comments
Closed

Missing NULL check #173

ManSoSec opened this issue Dec 11, 2019 · 0 comments
Assignees

Comments

@ManSoSec
Copy link

ManSoSec commented Dec 11, 2019

A NULL check on mspace is missing here:

libredwg/src/out_dxfb.c

Lines 1869 to 1879 in 785df5f

Dwg_Object *mspace = dwg->header_vars.BLOCK_RECORD_MSPACE->obj;
SECTION (ENTITIES);
for (i = 0; (BITCODE_BL)i < dwg->num_objects; i++)
{
Dwg_Object *obj = &dwg->object[i];
if (obj->supertype == DWG_SUPERTYPE_ENTITY && obj->type != DWG_TYPE_BLOCK
&& obj->type != DWG_TYPE_ENDBLK)
{
Dwg_Object_Ref *owner = obj->tio.entity->ownerhandle;
if (!owner || (owner && owner->obj == mspace))

While it is done here, which is a similar case:

libredwg/src/out_dxf.c

Lines 2261 to 2274 in 785df5f

Dwg_Object *mspace = dwg_model_space_object (dwg);
if (!mspace)
return DWG_ERR_INVALIDDWG;
SECTION (ENTITIES);
for (i = 0; (BITCODE_BL)i < dwg->num_objects; i++)
{
Dwg_Object *obj = &dwg->object[i];
if (obj->supertype == DWG_SUPERTYPE_ENTITY && obj->type != DWG_TYPE_BLOCK
&& obj->type != DWG_TYPE_ENDBLK)
{
Dwg_Object_Ref *owner = obj->tio.entity->ownerhandle;
if (!owner || (owner && owner->obj == mspace))

dwg_model_space_object might return dwg->header_vars.BLOCK_RECORD_MSPACE->obj so I think the semantic is the same.

return dwg->header_vars.BLOCK_RECORD_MSPACE->obj;

@rurban rurban self-assigned this Dec 25, 2019
rurban added a commit that referenced this issue Dec 26, 2019
Fixes GH #173, esp. add the new mspace improvements.
rurban added a commit that referenced this issue Dec 26, 2019
Fixes GH #173, esp. add the new mspace improvements.
rurban added a commit that referenced this issue Dec 26, 2019
Fixes GH #173, esp. add the new mspace improvements.
rurban added a commit that referenced this issue Dec 26, 2019
Fixes GH #173, esp. add the new mspace improvements.
@rurban rurban closed this as completed Dec 26, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants