Skip to content

Commit

Permalink
Defend buffer create
Browse files Browse the repository at this point in the history
  • Loading branch information
dixyes committed Nov 28, 2024
1 parent db35d83 commit 9850f7e
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions ext/src/swow_buffer.c
Original file line number Diff line number Diff line change
Expand Up @@ -1026,9 +1026,11 @@ static char *swow_buffer_realloc_standard(char *old_value, size_t new_size)
zend_string_forget_hash_val(new_string);
} else {
new_string = zend_string_alloc(new_size, false);
memcpy(ZSTR_VAL(new_string), ZSTR_VAL(old_string), new_length);
if (old_string != NULL && !ZSTR_IS_INTERNED(old_string)) {
GC_DELREF(old_string);
if (old_string != NULL) {
memcpy(ZSTR_VAL(new_string), ZSTR_VAL(old_string), new_length);
if (!ZSTR_IS_INTERNED(old_string)) {
GC_DELREF(old_string);
}
}
}
ZSTR_VAL(new_string)[ZSTR_LEN(new_string) = new_length] = '\0';
Expand Down

0 comments on commit 9850f7e

Please sign in to comment.