For Programmers: Free Programming Magazines  


Home > Archive > PHP Zend Engine > October 2006 > cvs: ZendEngine2 / zend_API.h









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author cvs: ZendEngine2 / zend_API.h
Andrei Zmievski

2006-10-19, 6:55 pm

andrei Thu Oct 19 20:54:48 2006 UTC

Modified files:
/ZendEngine2 zend_API.h
Log:
Fix potential (and real) leaks due to bad macro writing. Grrr.


http://cvs.php.net/viewvc.cgi/ZendE...6&diff_format=u
Index: ZendEngine2/zend_API.h
diff -u ZendEngine2/zend_API.h:1.265 ZendEngine2/zend_API.h:1.266
--- ZendEngine2/zend_API.h:1.265 Thu Oct 19 18:27:35 2006
+++ ZendEngine2/zend_API.h Thu Oct 19 20:54:48 2006
@@ -18,7 +18,7 @@
+----------------------------------------------------------------------+
*/

-/* $Id: zend_API.h,v 1.265 2006/10/19 18:27:35 andrei Exp $ */
+/* $Id: zend_API.h,v 1.266 2006/10/19 20:54:48 andrei Exp $ */

#ifndef ZEND_API_H
#define ZEND_API_H
@@ -1599,12 +1599,13 @@

#define ZVAL_ASCII_STRING(z, s, flags) \
if (UG(unicode)) { \
- uint length = strlen(s); \
- UChar *u_str = zend_ascii_to_unicode((s), length+1 ZEND_FILE_LINE_CC); \
+ char *__s = (s); \
+ int __s_len = strlen(__s); \
+ UChar *u_str = zend_ascii_to_unicode(__s, __s_len+1 ZEND_FILE_LINE_CC); \
if ((flags) & ZSTR_AUTOFREE) { \
- efree(s); \
+ efree(__s); \
} \
- ZVAL_UNICODEL(z, u_str, length, 0); \
+ ZVAL_UNICODEL(z, u_str, __s_len, 0); \
} else { \
char *__s=(s); \
Z_STRLEN_P(z) = strlen(__s); \
@@ -1614,12 +1615,13 @@

#define ZVAL_ASCII_STRINGL(z, s, l, flags) \
if (UG(unicode)) { \
- int u_len = l; \
- UChar *u_str = zend_ascii_to_unicode((s), (u_len)+1 ZEND_FILE_LINE_CC); \
+ char *__s = (s); \
+ int __s_len = (l); \
+ UChar *u_str = zend_ascii_to_unicode((__s), (__s_len)+1 ZEND_FILE_LINE_CC); \
if ((flags) & ZSTR_AUTOFREE) { \
- efree(s); \
+ efree(__s); \
} \
- ZVAL_UNICODEL(z, u_str, u_len, 0); \
+ ZVAL_UNICODEL(z, u_str, __s_len, 0); \
} else { \
char *__s=(s); int __l=l; \
Z_STRLEN_P(z) = __l; \
@@ -1630,12 +1632,13 @@
#define ZVAL_U_STRING(conv, z, s, flags) \
if (UG(unicode)) { \
UErrorCode status = U_ZERO_ERROR; \
+ char *__s = (s); \
+ int __s_len = strlen(__s); \
UChar *u_str; \
int u_len; \
- uint length = strlen(s); \
- zend_string_to_unicode_ex(conv, &u_str, &u_len, s, length, &status); \
+ zend_string_to_unicode_ex(conv, &u_str, &u_len, __s, __s_len, &status); \
if ((flags) & ZSTR_AUTOFREE) { \
- efree(s); \
+ efree(__s); \
} \
ZVAL_UNICODEL(z, u_str, u_len, 0); \
} else { \
@@ -1648,11 +1651,13 @@
#define ZVAL_U_STRINGL(conv, z, s, l, flags) \
if (UG(unicode)) { \
UErrorCode status = U_ZERO_ERROR; \
+ char *__s = (s); \
+ int __s_len = (l); \
UChar *u_str; \
int u_len; \
- zend_string_to_unicode_ex(conv, &u_str, &u_len, s, l, &status); \
+ zend_string_to_unicode_ex(conv, &u_str, &u_len, __s, __s_len, &status); \
if ((flags) & ZSTR_AUTOFREE) { \
- efree(s); \
+ efree(__s); \
} \
ZVAL_UNICODEL(z, u_str, u_len, 0); \
} else { \
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com