Skip to content

Commit 269f1ba

Browse files
committed
even if export succeeded, was possible to return and access uninit'd array.
init the bu_external right away and make it explicit during export also.
1 parent dbc8329 commit 269f1ba

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

src/librt/binunif/db5_bin.c

+7-5
Original file line numberDiff line numberDiff line change
@@ -207,11 +207,13 @@ rt_binunif_export5(struct bu_external *ep,
207207
RT_CK_DB_INTERNAL(ip);
208208
bip = (struct rt_binunif_internal *)ip->idb_ptr;
209209
RT_CK_BINUNIF(bip);
210-
if (bip->count <= 0) /* nothing to convert */
211-
return 0;
212210

211+
/* inputs valid, so init before return */
213212
BU_EXTERNAL_INIT(ep);
214213

214+
if (bip->count <= 0) /* nothing to convert */
215+
return 0;
216+
215217
/*
216218
* Convert from internal (host) to database (network) format
217219
*/
@@ -477,9 +479,9 @@ int
477479
rt_binunif_get(struct bu_vls *logstr, const struct rt_db_internal *intern, const char *attr)
478480
{
479481
register struct rt_binunif_internal *bip=(struct rt_binunif_internal *)intern->idb_ptr;
480-
struct bu_external ext;
481-
size_t i;
482-
unsigned char *c;
482+
struct bu_external ext = BU_EXTERNAL_INIT_ZERO;
483+
size_t i;
484+
unsigned char *c;
483485

484486
RT_CHECK_BINUNIF(bip);
485487

0 commit comments

Comments
 (0)