Skip to content

Commit 027e54b

Browse files
committed
Merge branch 'maint'
2 parents bde25e9 + 35b6828 commit 027e54b

1 file changed

Lines changed: 7 additions & 3 deletions

File tree

lib/erl_interface/src/misc/ei_x_encode.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,13 @@ int x_fix_buff(ei_x_buff* x, int szneeded)
6969
{
7070
int sz = szneeded + ei_x_extra;
7171
if (sz > x->buffsz) {
72-
sz += ei_x_extra; /* to avoid reallocating each and every time */
73-
x->buffsz = sz;
74-
x->buff = ei_realloc(x->buff, sz);
72+
char* newbuff;
73+
sz += ei_x_extra; /* to avoid reallocating each and every time */
74+
newbuff = ei_realloc(x->buff, sz);
75+
if (newbuff == NULL)
76+
return 0; /* leave x->buff and x->buffsz intact on failure */
77+
x->buff = newbuff;
78+
x->buffsz = sz;
7579
}
7680
return x->buff != NULL;
7781
}

0 commit comments

Comments
 (0)