derick          Tue Sep  4 11:19:33 2007 UTC

  Modified files:              
    /php-src/main       snprintf.c 
  Log:
  - We have to store the original (allocated) pointer here as it was freed after
    the pointer itself was modified, otherwise we'll get an invalid free error
    here.
  
  
http://cvs.php.net/viewvc.cgi/php-src/main/snprintf.c?r1=1.58&r2=1.59&diff_format=u
Index: php-src/main/snprintf.c
diff -u php-src/main/snprintf.c:1.58 php-src/main/snprintf.c:1.59
--- php-src/main/snprintf.c:1.58        Fri Aug  3 14:30:59 2007
+++ php-src/main/snprintf.c     Tue Sep  4 11:19:33 2007
@@ -16,7 +16,7 @@
   +----------------------------------------------------------------------+
 */
 
-/* $Id: snprintf.c,v 1.58 2007/08/03 14:30:59 tony2001 Exp $ */
+/* $Id: snprintf.c,v 1.59 2007/09/04 11:19:33 derick Exp $ */
 
 
 #include "php.h"
@@ -597,7 +597,7 @@
 
        char num_buf[NUM_BUF_SIZE];
        char char_buf[2];                       /* for printing %% and 
%<unknown> */
-       zend_bool free_s; /* free string if allocated here */
+       char *s_to_free;  /* tmp var to keep the string to be freed in */
 
 #ifdef HAVE_LOCALE_H
        struct lconv *lconv = NULL;
@@ -630,7 +630,7 @@
                        alternate_form = print_sign = print_blank = NO;
                        pad_char = ' ';
                        prefix_char = NUL;
-                       free_s = 0;
+                       s_to_free = NULL;
                        s_unicode = 0;
 
                        fmt++;
@@ -989,7 +989,7 @@
                                                return (cc);
                                        }
                                        s = res;
-                                       free_s = 1;
+                                       s_to_free = s;
                                                
                                        pad_char = ' ';
                                        break;
@@ -1202,7 +1202,7 @@
                                s++;
                        }
 
-                       if (free_s) efree(s);
+                       if (s_to_free) efree(s_to_free);
 
                        if (adjust_width && adjust == LEFT && min_width > s_len)
                                PAD(min_width, s_len, pad_char);

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

Reply via email to