Commit: 79c6c93e0d7ed360e8b1f0209c5f3e10692309ac
Author: andrey <and...@php.net> Mon, 30 Jul 2012 21:50:13 +0300
Parents: 06e06f026d14e7d61f2ceb14445a683abbbf91bb
Branches: master
Link:
http://git.php.net/?p=php-src.git;a=commitdiff;h=79c6c93e0d7ed360e8b1f0209c5f3e10692309ac
Log:
Fix crashes with filenames that don't contain directory separator - generated
files like scanners/parsers.
Changed paths:
M ext/mysqlnd/mysqlnd_alloc.c
diff --git a/ext/mysqlnd/mysqlnd_alloc.c b/ext/mysqlnd/mysqlnd_alloc.c
index 65423e4..e681d33 100644
--- a/ext/mysqlnd/mysqlnd_alloc.c
+++ b/ext/mysqlnd/mysqlnd_alloc.c
@@ -81,9 +81,11 @@ void * _mysqlnd_emalloc(size_t size MYSQLND_MEM_D)
#if PHP_DEBUG
long * threshold = &MYSQLND_G(debug_emalloc_fail_threshold);
#endif
+ char * fn = NULL;
TRACE_ALLOC_ENTER(mysqlnd_emalloc_name);
- TRACE_ALLOC_INF_FMT("file=%-15s line=%4d",
strrchr(__zend_orig_filename, PHP_DIR_SEPARATOR) + 1, __zend_orig_lineno);
+ TRACE_ALLOC_INF_FMT("file=%-15s line=%4d",
+ (fn = strrchr(__zend_orig_filename, PHP_DIR_SEPARATOR))? fn +
1:__zend_orig_filename, __zend_orig_lineno);
#if PHP_DEBUG
/* -1 is also "true" */
@@ -116,9 +118,10 @@ void * _mysqlnd_pemalloc(size_t size, zend_bool persistent
MYSQLND_MEM_D)
#if PHP_DEBUG
long * threshold = persistent?
&MYSQLND_G(debug_malloc_fail_threshold):&MYSQLND_G(debug_emalloc_fail_threshold);
#endif
+ char * fn = NULL;
TRACE_ALLOC_ENTER(mysqlnd_pemalloc_name);
TRACE_ALLOC_INF_FMT("file=%-15s line=%4d persistent=%u",
- strrchr(__zend_orig_filename,
PHP_DIR_SEPARATOR) + 1, __zend_orig_lineno,persistent);
+ (fn = strrchr(__zend_orig_filename, PHP_DIR_SEPARATOR))? fn +
1:__zend_orig_filename, __zend_orig_lineno, persistent);
#if PHP_DEBUG
/* -1 is also "true" */
@@ -154,8 +157,10 @@ void * _mysqlnd_ecalloc(unsigned int nmemb, size_t size
MYSQLND_MEM_D)
#if PHP_DEBUG
long * threshold = &MYSQLND_G(debug_ecalloc_fail_threshold);
#endif
+ char * fn = NULL;
TRACE_ALLOC_ENTER(mysqlnd_ecalloc_name);
- TRACE_ALLOC_INF_FMT("file=%-15s line=%4d",
strrchr(__zend_orig_filename, PHP_DIR_SEPARATOR) + 1, __zend_orig_lineno);
+ TRACE_ALLOC_INF_FMT("file=%-15s line=%4d",
+ (fn = strrchr(__zend_orig_filename, PHP_DIR_SEPARATOR))? fn +
1:__zend_orig_filename, __zend_orig_lineno);
TRACE_ALLOC_INF_FMT("before: %lu", zend_memory_usage(FALSE TSRMLS_CC));
#if PHP_DEBUG
@@ -189,9 +194,10 @@ void * _mysqlnd_pecalloc(unsigned int nmemb, size_t size,
zend_bool persistent M
#if PHP_DEBUG
long * threshold = persistent?
&MYSQLND_G(debug_calloc_fail_threshold):&MYSQLND_G(debug_ecalloc_fail_threshold);
#endif
+ char * fn = NULL;
TRACE_ALLOC_ENTER(mysqlnd_pecalloc_name);
TRACE_ALLOC_INF_FMT("file=%-15s line=%4d persistent=%u",
- strrchr(__zend_orig_filename,
PHP_DIR_SEPARATOR) + 1, __zend_orig_lineno, persistent);
+ (fn = strrchr(__zend_orig_filename, PHP_DIR_SEPARATOR))? fn +
1:__zend_orig_filename, __zend_orig_lineno, persistent);
#if PHP_DEBUG
/* -1 is also "true" */
@@ -228,8 +234,10 @@ void * _mysqlnd_erealloc(void *ptr, size_t new_size
MYSQLND_MEM_D)
#if PHP_DEBUG
long * threshold = &MYSQLND_G(debug_erealloc_fail_threshold);
#endif
+ char * fn = NULL;
TRACE_ALLOC_ENTER(mysqlnd_erealloc_name);
- TRACE_ALLOC_INF_FMT("file=%-15s line=%4d",
strrchr(__zend_orig_filename, PHP_DIR_SEPARATOR) + 1, __zend_orig_lineno);
+ TRACE_ALLOC_INF_FMT("file=%-15s line=%4d",
+ (fn = strrchr(__zend_orig_filename, PHP_DIR_SEPARATOR))? fn +
1:__zend_orig_filename, __zend_orig_lineno);
TRACE_ALLOC_INF_FMT("ptr=%p old_size=%lu, new_size=%lu", ptr, old_size,
new_size);
#if PHP_DEBUG
@@ -263,8 +271,10 @@ void * _mysqlnd_perealloc(void *ptr, size_t new_size,
zend_bool persistent MYSQL
#if PHP_DEBUG
long * threshold = persistent?
&MYSQLND_G(debug_realloc_fail_threshold):&MYSQLND_G(debug_erealloc_fail_threshold);
#endif
+ char * fn = NULL;
TRACE_ALLOC_ENTER(mysqlnd_perealloc_name);
- TRACE_ALLOC_INF_FMT("file=%-15s line=%4d",
strrchr(__zend_orig_filename, PHP_DIR_SEPARATOR) + 1, __zend_orig_lineno);
+ TRACE_ALLOC_INF_FMT("file=%-15s line=%4d",
+ (fn = strrchr(__zend_orig_filename, PHP_DIR_SEPARATOR))? fn +
1:__zend_orig_filename, __zend_orig_lineno);
TRACE_ALLOC_INF_FMT("ptr=%p old_size=%lu new_size=%lu persistent=%u",
ptr, old_size, new_size, persistent);
#if PHP_DEBUG
@@ -297,8 +307,10 @@ void _mysqlnd_efree(void *ptr MYSQLND_MEM_D)
{
size_t free_amount = 0;
zend_bool collect_memory_statistics =
MYSQLND_G(collect_memory_statistics);
+ char * fn = NULL;
TRACE_ALLOC_ENTER(mysqlnd_efree_name);
- TRACE_ALLOC_INF_FMT("file=%-15s line=%4d",
strrchr(__zend_orig_filename, PHP_DIR_SEPARATOR) + 1, __zend_orig_lineno);
+ TRACE_ALLOC_INF_FMT("file=%-15s line=%4d",
+ (fn = strrchr(__zend_orig_filename, PHP_DIR_SEPARATOR))? fn +
1:__zend_orig_filename, __zend_orig_lineno);
TRACE_ALLOC_INF_FMT("ptr=%p", ptr);
if (ptr) {
@@ -322,8 +334,10 @@ void _mysqlnd_pefree(void *ptr, zend_bool persistent
MYSQLND_MEM_D)
{
size_t free_amount = 0;
zend_bool collect_memory_statistics =
MYSQLND_G(collect_memory_statistics);
+ char * fn = NULL;
TRACE_ALLOC_ENTER(mysqlnd_pefree_name);
- TRACE_ALLOC_INF_FMT("file=%-15s line=%4d",
strrchr(__zend_orig_filename, PHP_DIR_SEPARATOR) + 1, __zend_orig_lineno);
+ TRACE_ALLOC_INF_FMT("file=%-15s line=%4d",
+ (fn = strrchr(__zend_orig_filename, PHP_DIR_SEPARATOR))? fn +
1:__zend_orig_filename, __zend_orig_lineno);
TRACE_ALLOC_INF_FMT("ptr=%p persistent=%u", ptr, persistent);
if (ptr) {
@@ -351,8 +365,10 @@ void * _mysqlnd_malloc(size_t size MYSQLND_MEM_D)
#if PHP_DEBUG
long * threshold = &MYSQLND_G(debug_malloc_fail_threshold);
#endif
+ char * fn = NULL;
TRACE_ALLOC_ENTER(mysqlnd_malloc_name);
- TRACE_ALLOC_INF_FMT("file=%-15s line=%4d",
strrchr(__zend_orig_filename, PHP_DIR_SEPARATOR) + 1, __zend_orig_lineno);
+ TRACE_ALLOC_INF_FMT("file=%-15s line=%4d",
+ (fn = strrchr(__zend_orig_filename, PHP_DIR_SEPARATOR))? fn +
1:__zend_orig_filename, __zend_orig_lineno);
#if PHP_DEBUG
/* -1 is also "true" */
@@ -384,8 +400,10 @@ void * _mysqlnd_calloc(unsigned int nmemb, size_t size
MYSQLND_MEM_D)
#if PHP_DEBUG
long * threshold = &MYSQLND_G(debug_calloc_fail_threshold);
#endif
+ char * fn = NULL;
TRACE_ALLOC_ENTER(mysqlnd_calloc_name);
- TRACE_ALLOC_INF_FMT("file=%-15s line=%4d",
strrchr(__zend_orig_filename, PHP_DIR_SEPARATOR) + 1, __zend_orig_lineno);
+ TRACE_ALLOC_INF_FMT("file=%-15s line=%4d",
+ (fn = strrchr(__zend_orig_filename, PHP_DIR_SEPARATOR))? fn +
1:__zend_orig_filename, __zend_orig_lineno);
#if PHP_DEBUG
/* -1 is also "true" */
@@ -417,8 +435,10 @@ void * _mysqlnd_realloc(void *ptr, size_t new_size
MYSQLND_MEM_D)
#if PHP_DEBUG
long * threshold = &MYSQLND_G(debug_realloc_fail_threshold);
#endif
+ char * fn = NULL;
TRACE_ALLOC_ENTER(mysqlnd_realloc_name);
- TRACE_ALLOC_INF_FMT("file=%-15s line=%4d",
strrchr(__zend_orig_filename, PHP_DIR_SEPARATOR) + 1, __zend_orig_lineno);
+ TRACE_ALLOC_INF_FMT("file=%-15s line=%4d",
+ (fn = strrchr(__zend_orig_filename, PHP_DIR_SEPARATOR))? fn +
1:__zend_orig_filename, __zend_orig_lineno);
TRACE_ALLOC_INF_FMT("ptr=%p new_size=%lu ", new_size, ptr);
TRACE_ALLOC_INF_FMT("before: %lu", zend_memory_usage(TRUE TSRMLS_CC));
@@ -450,8 +470,10 @@ void _mysqlnd_free(void *ptr MYSQLND_MEM_D)
{
size_t free_amount = 0;
zend_bool collect_memory_statistics =
MYSQLND_G(collect_memory_statistics);
+ char * fn = NULL;
TRACE_ALLOC_ENTER(mysqlnd_free_name);
- TRACE_ALLOC_INF_FMT("file=%-15s line=%4d",
strrchr(__zend_orig_filename, PHP_DIR_SEPARATOR) + 1, __zend_orig_lineno);
+ TRACE_ALLOC_INF_FMT("file=%-15s line=%4d",
+ (fn = strrchr(__zend_orig_filename, PHP_DIR_SEPARATOR))? fn +
1:__zend_orig_filename, __zend_orig_lineno);
TRACE_ALLOC_INF_FMT("ptr=%p", ptr);
if (ptr) {
@@ -479,8 +501,10 @@ char * _mysqlnd_pestrndup(const char * const ptr, size_t
length, zend_bool persi
{
char * ret;
zend_bool collect_memory_statistics =
MYSQLND_G(collect_memory_statistics);
+ char * fn = NULL;
TRACE_ALLOC_ENTER(mysqlnd_pestrndup_name);
- TRACE_ALLOC_INF_FMT("file=%-15s line=%4d",
strrchr(__zend_orig_filename, PHP_DIR_SEPARATOR) + 1, __zend_orig_lineno);
+ TRACE_ALLOC_INF_FMT("file=%-15s line=%4d",
+ (fn = strrchr(__zend_orig_filename, PHP_DIR_SEPARATOR))? fn +
1:__zend_orig_filename, __zend_orig_lineno);
TRACE_ALLOC_INF_FMT("ptr=%p", ptr);
ret = (persistent) ? __zend_malloc(REAL_SIZE(length + 1)) :
_emalloc(REAL_SIZE(length + 1) ZEND_FILE_LINE_CC ZEND_FILE_LINE_ORIG_RELAY_CC);
@@ -511,8 +535,10 @@ char * _mysqlnd_pestrdup(const char * const ptr, zend_bool
persistent MYSQLND_ME
smart_str tmp_str = {0, 0, 0};
const char * p = ptr;
zend_bool collect_memory_statistics =
MYSQLND_G(collect_memory_statistics);
+ char * fn = NULL;
TRACE_ALLOC_ENTER(mysqlnd_pestrdup_name);
- TRACE_ALLOC_INF_FMT("file=%-15s line=%4d",
strrchr(__zend_orig_filename, PHP_DIR_SEPARATOR) + 1, __zend_orig_lineno);
+ TRACE_ALLOC_INF_FMT("file=%-15s line=%4d",
+ (fn = strrchr(__zend_orig_filename, PHP_DIR_SEPARATOR))? fn +
1:__zend_orig_filename, __zend_orig_lineno);
TRACE_ALLOC_INF_FMT("ptr=%p", ptr);
do {
smart_str_appendc(&tmp_str, *p);
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php