Please review the attached patch which avoids an unnecessary strlen
call (in the NSAPI plugin for PHP) by using php_register_variable_safe
instead of php_register_variable.
thanks,
arvi
diff -r 64f24a22f518 sapi/nsapi/nsapi.c
--- a/sapi/nsapi/nsapi.c Wed Aug 26 17:33:06 2009 +0530
+++ b/sapi/nsapi/nsapi.c Thu Aug 27 17:26:55 2009 +0530
@@ -746,21 +746,16 @@
efree(value);
}
} else {
- php_register_variable("REQUEST_URI",
SG(request_info).request_uri, track_vars_array TSRMLS_CC);
+ php_register_variable_safe("REQUEST_URI",
SG(request_info).request_uri, pos, track_vars_array TSRMLS_CC);
}
- if (value = nsapi_strdup(SG(request_info).request_uri)) {
- if (rc->path_info) {
- pos = strlen(SG(request_info).request_uri) -
strlen(rc->path_info);
- if (pos>=0) {
- value[pos] = '\0';
- } else {
- value[0]='\0';
- }
+ if (rc->path_info) {
+ pos -= strlen(rc->path_info);
+ if (pos<0) {
+ pos = 0;
}
- php_register_variable("SCRIPT_NAME", value,
track_vars_array TSRMLS_CC);
- nsapi_free(value);
}
+ php_register_variable_safe("SCRIPT_NAME", value, pos,
track_vars_array TSRMLS_CC);
}
php_register_variable("SCRIPT_FILENAME",
SG(request_info).path_translated, track_vars_array TSRMLS_CC);
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php