cvs: php4 /ext/session mod_mm.c
| From: | Sascha Schumann | Date: | Thu, 10 Jan 2002 07:37:10 +0000 |
| Subject: | cvs: php4 /ext/session mod_mm.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-9028@lists.php.net to get a copy of this message | ||
sas Thu Jan 10 02:37:10 2002 EDT
Modified files:
/php4/ext/session mod_mm.c
Log:
Improved code for handling PS(save_path)
Don't MFH before further testing
Index: php4/ext/session/mod_mm.c
diff -u php4/ext/session/mod_mm.c:1.27 php4/ext/session/mod_mm.c:1.28
--- php4/ext/session/mod_mm.c:1.27 Thu Jan 10 02:28:27 2002
+++ php4/ext/session/mod_mm.c Thu Jan 10 02:37:10 2002
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: mod_mm.c,v 1.27 2002/01/10 07:28:27 sas Exp $ */
+/* $Id: mod_mm.c,v 1.28 2002/01/10 07:37:10 sas Exp $ */
#include "php.h"
@@ -247,18 +247,29 @@
PHP_MINIT_FUNCTION(ps_mm)
{
- char *ps_mm_path = calloc(strlen(PS(save_path))+1+strlen(PS_MM_FILE)+1, 1); /* Directory +
'/' + File + \0 */
+ int len = strlen(PS(save_path));
+ char *ps_mm_path;
+ int ret;
ps_mm_instance = calloc(sizeof(*ps_mm_instance), 1);
+ if (!ps_mm_instance)
+ return FAILURE;
+
+ ps_mm_path = do_alloca(len + 1 + sizeof(PS_MM_FILE)); /* Directory + '/' + File + \0 */
- strcpy(ps_mm_path, PS(save_path));
+ memcpy(ps_mm_path, PS(save_path), len + 1);
- if((strlen(ps_mm_path) > 0) && (ps_mm_path[strlen(ps_mm_path)-1] != '/'))
- strcat(ps_mm_path, "/"); /* Fixme Windows */
+ if (len > 0 && ps_mm_path[len - 1] != DEFAULT_DIR_SEPARATOR)
+ strcat(ps_mm_path, DEFAULT_DIR_SEPARATOR);
strcat(ps_mm_path, PS_MM_FILE);
- if (ps_mm_initialize(ps_mm_instance, ps_mm_path) != SUCCESS) {
+ ret = ps_mm_initialize(ps_mm_instance, ps_mm_path);
+
+ free_alloca(ps_mm_path);
+
+ if (ret != SUCCESS) {
+ free(ps_mm_instance);
ps_mm_instance = NULL;
return FAILURE;
}