Use ruby_xfree to free buffers

They are allocated with ruby_xmalloc, they should be freed with
ruby_xfree.
This commit is contained in:
Jean Boussier 2023-02-20 11:09:32 +01:00 committed by Hiroshi SHIBATA
parent 32f289d118
commit 698cb84062
No known key found for this signature in database
GPG Key ID: F9CF13417264FAC2
2 changed files with 8 additions and 8 deletions

View File

@ -1497,7 +1497,7 @@ static VALUE json_string_unescape(char *string, char *stringEnd, int intern, int
case 'u':
if (pe > stringEnd - 4) {
if (bufferSize > MAX_STACK_BUFFER_SIZE) {
free(bufferStart);
ruby_xfree(bufferStart);
}
rb_enc_raise(
EXC_ENCODING eParserError,
@ -1510,7 +1510,7 @@ static VALUE json_string_unescape(char *string, char *stringEnd, int intern, int
pe++;
if (pe > stringEnd - 6) {
if (bufferSize > MAX_STACK_BUFFER_SIZE) {
free(bufferStart);
ruby_xfree(bufferStart);
}
rb_enc_raise(
EXC_ENCODING eParserError,
@ -1555,13 +1555,13 @@ static VALUE json_string_unescape(char *string, char *stringEnd, int intern, int
result = rb_utf8_str_new(bufferStart, (long)(buffer - bufferStart));
}
if (bufferSize > MAX_STACK_BUFFER_SIZE) {
free(bufferStart);
ruby_xfree(bufferStart);
}
# else
result = rb_utf8_str_new(bufferStart, (long)(buffer - bufferStart));
if (bufferSize > MAX_STACK_BUFFER_SIZE) {
free(bufferStart);
ruby_xfree(bufferStart);
}
if (intern) {

View File

@ -508,7 +508,7 @@ static VALUE json_string_unescape(char *string, char *stringEnd, int intern, int
case 'u':
if (pe > stringEnd - 4) {
if (bufferSize > MAX_STACK_BUFFER_SIZE) {
free(bufferStart);
ruby_xfree(bufferStart);
}
rb_enc_raise(
EXC_ENCODING eParserError,
@ -521,7 +521,7 @@ static VALUE json_string_unescape(char *string, char *stringEnd, int intern, int
pe++;
if (pe > stringEnd - 6) {
if (bufferSize > MAX_STACK_BUFFER_SIZE) {
free(bufferStart);
ruby_xfree(bufferStart);
}
rb_enc_raise(
EXC_ENCODING eParserError,
@ -566,13 +566,13 @@ static VALUE json_string_unescape(char *string, char *stringEnd, int intern, int
result = rb_utf8_str_new(bufferStart, (long)(buffer - bufferStart));
}
if (bufferSize > MAX_STACK_BUFFER_SIZE) {
free(bufferStart);
ruby_xfree(bufferStart);
}
# else
result = rb_utf8_str_new(bufferStart, (long)(buffer - bufferStart));
if (bufferSize > MAX_STACK_BUFFER_SIZE) {
free(bufferStart);
ruby_xfree(bufferStart);
}
if (intern) {