Skip to content

Commit

Permalink
maptree.c: fix warning about nullptr deref (CID 1174351)
Browse files Browse the repository at this point in the history
  • Loading branch information
rouault committed May 23, 2021
1 parent 98b8572 commit 972e512
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions maptree.c
Expand Up @@ -608,13 +608,15 @@ treeNodeObj *readTreeNode( SHPTreeHandle disktree )
return NULL;
}
if( node->numshapes > 0 )
node->ids = (ms_int32 *)msSmallMalloc(sizeof(ms_int32)*node->numshapes);
res = fread( node->ids, node->numshapes*4, 1, disktree->fp );
if ( !res )
{
free(node->ids);
free(node);
return NULL;
node->ids = (ms_int32 *)msSmallMalloc(sizeof(ms_int32)*node->numshapes);
res = fread( node->ids, node->numshapes*4, 1, disktree->fp );
if ( !res )
{
free(node->ids);
free(node);
return NULL;
}
}
for( i=0; i < node->numshapes; i++ ) {
if ( disktree->needswap ) SwapWord ( 4, &node->ids[i] );
Expand Down

0 comments on commit 972e512

Please sign in to comment.