summaryrefslogtreecommitdiff
path: root/sapi/embed/php_embed.c
diff options
context:
space:
mode:
authorMarcus Boerger <helly@php.net>2008-03-25 22:04:58 +0000
committerMarcus Boerger <helly@php.net>2008-03-25 22:04:58 +0000
commit97781b818b25d6a2d3e7aca6196dc8aefde558fb (patch)
tree530ae46cd9830d9ff16c9d966ab0e0e445c20683 /sapi/embed/php_embed.c
parentbd366b66da9b0d7b92efab00f538d5d3aacd6f16 (diff)
downloadphp-git-97781b818b25d6a2d3e7aca6196dc8aefde558fb.tar.gz
- Fix memory leak found by Osman
- Merge strlen to sizof change from CLI
Diffstat (limited to 'sapi/embed/php_embed.c')
-rw-r--r--sapi/embed/php_embed.c37
1 files changed, 17 insertions, 20 deletions
diff --git a/sapi/embed/php_embed.c b/sapi/embed/php_embed.c
index 7e8eccbe40..5c3bf1197c 100644
--- a/sapi/embed/php_embed.c
+++ b/sapi/embed/php_embed.c
@@ -25,13 +25,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)
{
@@ -158,7 +158,6 @@ int php_embed_init(int argc, char **argv PTSRMLS_DC)
#ifdef ZTS
void ***tsrm_ls = NULL;
#endif
- int ini_entries_len = 0;
#ifdef HAVE_SIGNAL_H
#if defined(SIGPIPE) && defined(SIG_IGN)
@@ -171,6 +170,14 @@ int php_embed_init(int argc, char **argv PTSRMLS_DC)
#endif
#endif
+#ifdef ZTS
+ tsrm_startup(1, 1, 0, NULL);
+ tsrm_ls = ts_resource(0);
+ *ptsrm_ls = tsrm_ls;
+#endif
+
+ 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 */
@@ -178,21 +185,11 @@ int php_embed_init(int argc, char **argv PTSRMLS_DC)
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
+ php_embed_module.ini_entries = malloc(sizeof(HARDCODED_INI));
+ memcpy(php_embed_module.ini_entries, HARDCODED_INI, sizeof(HARDCODED_INI));
php_embed_module.additional_functions = additional_functions;
- 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);
-
if (argv) {
php_embed_module.executable_location = argv[0];
}