helly           Sat Jan 10 08:23:59 2004 EDT

  Modified files:              
    /php-src/ext/libxml libxml.c php_libxml.h 
  Log:
  Fix memory corruption with libxml's error handling.
  
  
Index: php-src/ext/libxml/libxml.c
diff -u php-src/ext/libxml/libxml.c:1.13 php-src/ext/libxml/libxml.c:1.14
--- php-src/ext/libxml/libxml.c:1.13    Thu Jan  8 03:15:56 2004
+++ php-src/ext/libxml/libxml.c Sat Jan 10 08:23:58 2004
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: libxml.c,v 1.13 2004/01/08 08:15:56 andi Exp $ */
+/* $Id: libxml.c,v 1.14 2004/01/10 13:23:58 helly Exp $ */
 
 #define IS_EXT_MODULE
 
@@ -225,7 +225,7 @@
 static void php_libxml_init_globals(php_libxml_globals *libxml_globals_p TSRMLS_DC)
 {
        LIBXML(stream_context) = NULL;
-       LIBXML(error_buffer) = NULL;
+       LIBXML(error_buffer).c = NULL;
 }
 #endif
 
@@ -336,16 +336,15 @@
        if (output == 1) {
                switch (error_type) {
                        case PHP_LIBXML_CTX_ERROR:
-                               php_libxml_ctx_error_level(E_WARNING, ctx, (char *) 
LIBXML(error_buffer) TSRMLS_CC);
+                               php_libxml_ctx_error_level(E_WARNING, ctx, 
LIBXML(error_buffer).c TSRMLS_CC);
                                break;
                        case PHP_LIBXML_CTX_WARNING:
-                               php_libxml_ctx_error_level(E_NOTICE, ctx, (char *) 
LIBXML(error_buffer) TSRMLS_CC);
+                               php_libxml_ctx_error_level(E_NOTICE, ctx, 
LIBXML(error_buffer).c TSRMLS_CC);
                                break;
                        default:
-                               php_error(E_WARNING, "%s", (char *) 
LIBXML(error_buffer));
+                               php_error(E_WARNING, "%s", LIBXML(error_buffer).c);
                }
                smart_str_free(&LIBXML(error_buffer));
-               LIBXML(error_buffer) = NULL;
        }
 }
 
@@ -419,7 +418,7 @@
        ts_allocate_id(&libxml_globals_id, sizeof(php_libxml_globals), 
(ts_allocate_ctor) php_libxml_init_globals, NULL);
 #else
        LIBXML(stream_context) = NULL;
-       LIBXML(error_buffer) = NULL;
+       LIBXML(error_buffer).c = NULL;
 #endif
 
        return SUCCESS;
@@ -441,10 +440,7 @@
 
 PHP_RSHUTDOWN_FUNCTION(libxml)
 {
-       if (LIBXML(error_buffer)) {
-               smart_str_free(&LIBXML(error_buffer));
-               LIBXML(error_buffer) = NULL;
-       }
+       smart_str_free(&LIBXML(error_buffer));
        return SUCCESS;
 }
 
Index: php-src/ext/libxml/php_libxml.h
diff -u php-src/ext/libxml/php_libxml.h:1.6 php-src/ext/libxml/php_libxml.h:1.7
--- php-src/ext/libxml/php_libxml.h:1.6 Thu Jan  8 12:32:20 2004
+++ php-src/ext/libxml/php_libxml.h     Sat Jan 10 08:23:58 2004
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: php_libxml.h,v 1.6 2004/01/08 17:32:20 sniper Exp $ */
+/* $Id: php_libxml.h,v 1.7 2004/01/10 13:23:58 helly Exp $ */
 
 #ifndef PHP_LIBXML_H
 #define PHP_LIBXML_H
@@ -42,7 +42,7 @@
 
 typedef struct {
        zval *stream_context;
-       smart_str *error_buffer;
+       smart_str error_buffer;
 } php_libxml_globals;
 
 typedef struct _php_libxml_ref_obj {

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to