Skip to content

Commit

Permalink
explicitly zero out new memory before we initialize it
Browse files Browse the repository at this point in the history
this fixes semi-random instances of "charstring parse error" in mergefonts
  • Loading branch information
cjchapman authored and miguelsousa committed May 9, 2019
1 parent b97a8c0 commit e25ae14
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions c/public/lib/source/dynarr/dynarr.c
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,10 @@ long dnaGrow(void *object, size_t elemsize, long index) {
if (new_ptr == NULL) {
return -1; /* Allocation failed */
}

/* explictly zero out the new memory before initialization */
memset((char *)new_ptr + (da->size * elemsize), 0, (new_size - da->size) * elemsize);

if (da->func != NULL) {
/* Initialize newly allocated elements */
/* 64-bit warning fixed by cast here */
Expand Down

0 comments on commit e25ae14

Please sign in to comment.