Skip to content

Commit

Permalink
memcpy & qsort with null ptr
Browse files Browse the repository at this point in the history
  • Loading branch information
atupone committed May 21, 2024
1 parent 3f3d875 commit 850b643
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/scene/Octree.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,8 @@ OctreeNode::OctreeNode(unsigned char _depth, const Extents& exts,
// copy the incoming list
const int listBytes = _listSize * sizeof(SceneNode*);
list = (SceneNode**)malloc(listBytes);
memcpy(list, _list, listBytes);
if (listBytes)
memcpy(list, _list, listBytes);

// copy the extents, and make a slighty puffed up version
extents = exts;
Expand Down
3 changes: 2 additions & 1 deletion src/scene/ZSceneDatabase.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,8 @@ void ZSceneDatabase::makeCuller()
TimeKeeper startTime = TimeKeeper::getCurrent();

// sorted from lowest to highest
qsort(staticList, staticCount, sizeof(SceneNode*), compareZExtents);
if (staticCount)
qsort(staticList, staticCount, sizeof(SceneNode*), compareZExtents);

// make the tree
octree->addNodes (staticList, staticCount, cullDepth, cullElements);
Expand Down

0 comments on commit 850b643

Please sign in to comment.