Skip to content

json_last_error_msg - better message - error position near by #18866

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 12 commits into
base: master
Choose a base branch
from
Prev Previous commit
Next Next commit
memory leak fixed with old school
  • Loading branch information
juan-morales committed Jun 10, 2025
commit b4343011829a44af918d764a322bcdf950583030
7 changes: 6 additions & 1 deletion ext/json/json.c
Original file line number Diff line number Diff line change
Expand Up @@ -375,6 +375,11 @@ PHP_FUNCTION(json_last_error_msg)
{
ZEND_PARSE_PARAMETERS_NONE();

RETURN_STRING(php_json_get_error_msg(JSON_G(error_code)));
char *msg = php_json_get_error_msg(JSON_G(error_code));
RETVAL_STRING(msg);
if (JSON_G(error_code) == PHP_JSON_ERROR_SYNTAX) {
efree(msg);
}
//original:RETURN_STRING(php_json_get_error_msg(JSON_G(error_code)));
}
/* }}} */