Skip to content

Commit 73a671e

Browse files
committed
POC
1 parent b434301 commit 73a671e

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

ext/json/json.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -158,9 +158,7 @@ static const char *php_json_get_error_msg(php_json_error_code error_code) /* {{{
158158
case PHP_JSON_ERROR_CTRL_CHAR:
159159
return "Control character error, possibly incorrectly encoded";
160160
case PHP_JSON_ERROR_SYNTAX:
161-
char *msg;
162-
spprintf(&msg, 0, "Syntax error near character %zu", JSON_G(error_pos));
163-
return msg;
161+
return "Syntax error";
164162
case PHP_JSON_ERROR_UTF8:
165163
return "Malformed UTF-8 characters, possibly incorrectly encoded";
166164
case PHP_JSON_ERROR_RECURSION:
@@ -375,11 +373,13 @@ PHP_FUNCTION(json_last_error_msg)
375373
{
376374
ZEND_PARSE_PARAMETERS_NONE();
377375

378-
char *msg = php_json_get_error_msg(JSON_G(error_code));
379-
RETVAL_STRING(msg);
380376
if (JSON_G(error_code) == PHP_JSON_ERROR_SYNTAX) {
381-
efree(msg);
382-
}
383-
//original:RETURN_STRING(php_json_get_error_msg(JSON_G(error_code)));
377+
char *msg;
378+
spprintf(&msg, 0, "Syntax error near character %zu", JSON_G(error_pos));
379+
RETVAL_STRING(msg);
380+
efree(msg);
381+
} else {
382+
RETURN_STRING(php_json_get_error_msg(JSON_G(error_code)));
383+
}
384384
}
385385
/* }}} */

0 commit comments

Comments
 (0)