Skip to content

Commit

Permalink
can't malloc 0
Browse files Browse the repository at this point in the history
it's possible to create an empty bspline with 0 surfaces (with 'put'
namely) - don't worry with bu_calloc when this is the case
  • Loading branch information
f4alt committed Aug 10, 2023
1 parent 6a81a2a commit 005698e
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/librt/primitives/bspline/bspline.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1078,7 +1078,9 @@ rt_nurb_import5(struct rt_db_internal *ip, const struct bu_external *ep, const f

sip->nsrf = ntohl(*(uint32_t *)cp);
cp += SIZEOF_NETWORK_LONG;
sip->srfs = (struct face_g_snurb **) bu_calloc(sip->nsrf, sizeof(struct face_g_snurb *), "nurb srfs[]");

if (sip->nsrf > 0)
sip->srfs = (struct face_g_snurb **) bu_calloc(sip->nsrf, sizeof(struct face_g_snurb *), "nurb srfs[]");

for (s = 0; s < sip->nsrf; s++) {
struct face_g_snurb *srf;
Expand Down

0 comments on commit 005698e

Please sign in to comment.