From 37bc8289b99a69012d021b4a4e99ffd8f10bdada Mon Sep 17 00:00:00 2001 From: Antony Dovgal Date: Tue, 18 Oct 2005 12:41:13 +0000 Subject: [PATCH] fix mime_magic problems with ZTS --- ext/mime_magic/mime_magic.c | 12 +++++++++--- ext/mime_magic/phpmimemagic.h | 1 - 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/ext/mime_magic/mime_magic.c b/ext/mime_magic/mime_magic.c index 59644abaa7..0ec285b504 100644 --- a/ext/mime_magic/mime_magic.c +++ b/ext/mime_magic/mime_magic.c @@ -260,7 +260,9 @@ PHP_INI_END() */ static void php_mime_magic_init_globals(zend_mime_magic_globals *mime_magic_globals) { - mime_global.magicfile = NULL; + memset(mime_magic_globals, 0, sizeof(zend_mime_magic_globals)); + mime_global.magic = NULL; + mime_global.last = NULL; } /* }}} */ @@ -348,7 +350,7 @@ PHP_FUNCTION(mime_content_type) if (conf->magic == (struct magic *)-1) { if(MIME_MAGIC_G(debug)) - php_error_docref("http://www.php.net/mime_magic" TSRMLS_CC, E_ERROR, "mime_magic could not be initialized, magic file %s is not available", conf->magicfile); + php_error_docref("http://www.php.net/mime_magic" TSRMLS_CC, E_ERROR, "mime_magic could not be initialized, magic file %s is not available", MIME_MAGIC_G(magicfile)); RETURN_FALSE; } @@ -391,7 +393,11 @@ static int apprentice(void) magic_server_config_rec *conf = &mime_global; TSRMLS_FETCH(); - fname = conf->magicfile; /* todo cwd? */ + if (!MIME_MAGIC_G(magicfile)) { + return -1; + } + + fname = MIME_MAGIC_G(magicfile); /* todo cwd? */ f = fopen(fname, "rb"); if (f == NULL) { conf->magic = (struct magic *)-1; diff --git a/ext/mime_magic/phpmimemagic.h b/ext/mime_magic/phpmimemagic.h index 72d29ac6fa..9849030f92 100644 --- a/ext/mime_magic/phpmimemagic.h +++ b/ext/mime_magic/phpmimemagic.h @@ -343,7 +343,6 @@ typedef struct magic_rsl_s { /* per-server info */ typedef struct { - char *magicfile; /* where magic be found */ struct magic *magic; /* head of magic config list */ struct magic *last; } magic_server_config_rec; -- 2.40.0