[php-src] master: Convert last_error_file to zend_string
| From: | Nikita Popov | Date: | Fri, 23 Apr 2021 09:05:19 +0000 |
| Subject: | [php-src] master: Convert last_error_file to zend_string | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-115779@lists.php.net to get a copy of this message | ||
Author: Nikita Popov (nikic)
Date: 2021-04-23T11:05:14+02:00
Commit: https://github.com/php/php-src/commit/b66eb866c94d82f7b99ffc130fff5cfb2ff145b6
Raw diff: https://github.com/php/php-src/commit/b66eb866c94d82f7b99ffc130fff5cfb2ff145b6.diff
Convert last_error_file to zend_string
Changed paths:
M ext/standard/basic_functions.c
M main/main.c
M main/php_globals.h
M sapi/cli/php_cli_server.c
M sapi/phpdbg/phpdbg_info.c
Diff:
diff --git a/ext/standard/basic_functions.c b/ext/standard/basic_functions.c
index 0424bd9ab16eb..a614b40210ea7 100755
--- a/ext/standard/basic_functions.c
+++ b/ext/standard/basic_functions.c
@@ -1510,7 +1510,8 @@ PHP_FUNCTION(error_get_last)
add_assoc_long_ex(return_value, "type", sizeof("type")-1,
PG(last_error_type));
add_assoc_str_ex(return_value, "message", sizeof("message")-1,
zend_string_copy(PG(last_error_message)));
- add_assoc_string_ex(return_value, "file", sizeof("file")-1,
PG(last_error_file)?PG(last_error_file):"-");
+ add_assoc_str_ex(return_value, "file", sizeof("file")-1,
+ zend_string_copy(PG(last_error_file)));
add_assoc_long_ex(return_value, "line", sizeof("line")-1,
PG(last_error_lineno));
}
}
@@ -1529,7 +1530,7 @@ PHP_FUNCTION(error_clear_last)
PG(last_error_message) = NULL;
if (PG(last_error_file)) {
- free(PG(last_error_file));
+ zend_string_release(PG(last_error_file));
PG(last_error_file) = NULL;
}
}
diff --git a/main/main.c b/main/main.c
index 1988f3855a800..6fcfb47c2730b 100644
--- a/main/main.c
+++ b/main/main.c
@@ -1144,7 +1144,7 @@ static void clear_last_error() {
PG(last_error_message) = NULL;
}
if (PG(last_error_file)) {
- free(PG(last_error_file));
+ zend_string_release(PG(last_error_file));
PG(last_error_file) = NULL;
}
}
@@ -1188,7 +1188,7 @@ static ZEND_COLD void php_error_cb(int orig_type, zend_string *error_filename,
c
if (zend_string_equals(PG(last_error_message), message)
|| (!PG(ignore_repeated_source)
&& ((PG(last_error_lineno) != (int)error_lineno)
- || strcmp(PG(last_error_file), ZSTR_VAL(error_filename))))) {
+ || !zend_string_equals(PG(last_error_file), error_filename)))) {
display = 1;
} else {
display = 0;
@@ -1227,7 +1227,7 @@ static ZEND_COLD void php_error_cb(int orig_type, zend_string *error_filename,
c
}
PG(last_error_type) = type;
PG(last_error_message) = zend_string_copy(message);
- PG(last_error_file) = strdup(ZSTR_VAL(error_filename));
+ PG(last_error_file) = zend_string_copy(error_filename);
PG(last_error_lineno) = error_lineno;
}
diff --git a/main/php_globals.h b/main/php_globals.h
index e619694d18a52..71f2dbbf83697 100644
--- a/main/php_globals.h
+++ b/main/php_globals.h
@@ -134,7 +134,7 @@ struct _php_core_globals {
int last_error_type;
zend_string *last_error_message;
- char *last_error_file;
+ zend_string *last_error_file;
int last_error_lineno;
char *php_sys_temp_dir;
diff --git a/sapi/cli/php_cli_server.c b/sapi/cli/php_cli_server.c
index cb993b5bb606a..17e979cc0a97b 100644
--- a/sapi/cli/php_cli_server.c
+++ b/sapi/cli/php_cli_server.c
@@ -1169,7 +1169,7 @@ static void php_cli_server_log_response(php_cli_server_client *client, int
statu
/* error */
if (append_error_message) {
spprintf(&error_buf, 0, " - %s in %s on line %d",
- ZSTR_VAL(PG(last_error_message)), PG(last_error_file), PG(last_error_lineno));
+ ZSTR_VAL(PG(last_error_message)), ZSTR_VAL(PG(last_error_file)), PG(last_error_lineno));
if (!error_buf) {
efree(basic_buf);
if (message) {
diff --git a/sapi/phpdbg/phpdbg_info.c b/sapi/phpdbg/phpdbg_info.c
index b5dc4fa492713..c09358ca68a3d 100644
--- a/sapi/phpdbg/phpdbg_info.c
+++ b/sapi/phpdbg/phpdbg_info.c
@@ -83,7 +83,7 @@ PHPDBG_INFO(error) /* {{{ */
{
if (PG(last_error_message)) {
phpdbg_try_access {
- phpdbg_writeln("lasterror", "error=\"%s\" file=\"%s\"
line=\"%d\"", "Last error: %s at %s line %d", PG(last_error_message),
PG(last_error_file), PG(last_error_lineno));
+ phpdbg_writeln("lasterror", "error=\"%s\" file=\"%s\"
line=\"%d\"", "Last error: %s at %s line %d", PG(last_error_message),
ZSTR_VAL(PG(last_error_file)), PG(last_error_lineno));
} phpdbg_catch_access {
phpdbg_notice("lasterror", "error=\"\"", "No error
found!");
} phpdbg_end_try_access();