helly           Wed Mar 26 13:21:57 2008 UTC

  Modified files:              (Branch: PHP_5_2)
    /php-src/sapi/embed php_embed.c 
  Log:
  MFH:
  - Fix memory leak found by Osman
  - Merge strlen to sizof change from CLI
  
  
http://cvs.php.net/viewvc.cgi/php-src/sapi/embed/php_embed.c?r1=1.11.2.1.2.6&r2=1.11.2.1.2.7&diff_format=u
Index: php-src/sapi/embed/php_embed.c
diff -u php-src/sapi/embed/php_embed.c:1.11.2.1.2.6 
php-src/sapi/embed/php_embed.c:1.11.2.1.2.7
--- php-src/sapi/embed/php_embed.c:1.11.2.1.2.6 Mon Dec 31 07:20:16 2007
+++ php-src/sapi/embed/php_embed.c      Wed Mar 26 13:21:57 2008
@@ -15,7 +15,7 @@
    | Author: Edin Kadribasic <[EMAIL PROTECTED]>                              |
    +----------------------------------------------------------------------+
 */
-/* $Id: php_embed.c,v 1.11.2.1.2.6 2007/12/31 07:20:16 sebastian Exp $ */
+/* $Id: php_embed.c,v 1.11.2.1.2.7 2008/03/26 13:21:57 helly Exp $ */
 
 #include "php_embed.h"
 
@@ -24,13 +24,13 @@
 #include <fcntl.h>
 #endif
 
-#define HARDCODED_INI                  \
-       "html_errors=0\n"                       \
-       "register_argc_argv=1\n"        \
-       "implicit_flush=1\n"            \
-       "output_buffering=0\n"          \
-       "max_execution_time=0\n"        \
-       "max_input_time=-1\n"
+const char HARDCODED_INI[] =
+       "html_errors=0\n"
+       "register_argc_argv=1\n"
+       "implicit_flush=1\n"
+       "output_buffering=0\n"
+       "max_execution_time=0\n"
+       "max_input_time=-1\n\0";
 
 static char* php_embed_read_cookies(TSRMLS_D)
 {
@@ -145,7 +145,6 @@
 #ifdef ZTS
        void ***tsrm_ls = NULL;
 #endif
-       int ini_entries_len = 0;
 
 #ifdef HAVE_SIGNAL_H
 #if defined(SIGPIPE) && defined(SIG_IGN)
@@ -158,26 +157,24 @@
 #endif
 #endif
 
-#ifdef PHP_WIN32
-  _fmode = _O_BINARY;                  /*sets default for file streams to 
binary */
-  setmode(_fileno(stdin), O_BINARY);           /* make the stdio mode be 
binary */
-  setmode(_fileno(stdout), O_BINARY);          /* make the stdio mode be 
binary */
-  setmode(_fileno(stderr), O_BINARY);          /* make the stdio mode be 
binary */
-#endif
-
 #ifdef ZTS
   tsrm_startup(1, 1, 0, NULL);
   tsrm_ls = ts_resource(0);
   *ptsrm_ls = tsrm_ls;
 #endif
 
-  ini_entries_len = strlen(HARDCODED_INI);
-  php_embed_module.ini_entries = malloc(ini_entries_len+2);
-  memcpy(php_embed_module.ini_entries, HARDCODED_INI, ini_entries_len+1);
-  php_embed_module.ini_entries[ini_entries_len+1] = 0;
-
   sapi_startup(&php_embed_module);
 
+#ifdef PHP_WIN32
+  _fmode = _O_BINARY;                  /*sets default for file streams to 
binary */
+  setmode(_fileno(stdin), O_BINARY);           /* make the stdio mode be 
binary */
+  setmode(_fileno(stdout), O_BINARY);          /* make the stdio mode be 
binary */
+  setmode(_fileno(stderr), O_BINARY);          /* make the stdio mode be 
binary */
+#endif
+
+  php_embed_module.ini_entries = malloc(sizeof(HARDCODED_INI));
+  memcpy(php_embed_module.ini_entries, HARDCODED_INI, sizeof(HARDCODED_INI));
+
   if (argv) {
        php_embed_module.executable_location = argv[0];
   }



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

Reply via email to