]> granicus.if.org Git - php/commitdiff
add test for mkdir() of sub-directory of existing file, and restore the removed free...
authorGreg Beaver <cellog@php.net>
Mon, 14 Apr 2008 15:48:25 +0000 (15:48 +0000)
committerGreg Beaver <cellog@php.net>
Mon, 14 Apr 2008 15:48:25 +0000 (15:48 +0000)
ext/phar/dirstream.c
ext/phar/tests/dir.phpt

index c4f1ec3c791051a0b079ab3a37dc5976e515fddb..90e18183778d51164cc24807b1d82694a193f6e0 100644 (file)
@@ -458,6 +458,10 @@ int phar_wrapper_mkdir(php_stream_wrapper *wrapper, char *url_from, int mode, in
 
        if ((e = phar_get_entry_info_dir(phar, resource->path + 1, strlen(resource->path + 1), 2, &error TSRMLS_CC))) {
                /* directory exists, or is a subdirectory of an existing file */
+               if (e->is_temp_dir) {
+                       efree(e->filename);
+                       efree(e);
+               }
                php_stream_wrapper_log_error(wrapper, options TSRMLS_CC, "phar error: cannot create directory \"%s\" in phar \"%s\", directory already exists", resource->path+1, resource->host);
                php_url_free(resource);
                return FAILURE;
index 578e2df0125f96ee6db7b30e585c93b670fc5b45..1168bd50ea07d761f9c3234e705e26f187578360 100644 (file)
@@ -34,6 +34,8 @@ ini_set('phar.readonly', 0);
 // create new phar by mkdir
 mkdir('phar://' . dirname(__FILE__) . '/ok.phar/fails');
 mkdir('phar://' . dirname(__FILE__) . '/ok.phar/fails');
+file_put_contents('phar://' . dirname(__FILE__) . '/ok.phar/sub/directory.txt', 'hi');
+mkdir('phar://' . dirname(__FILE__) . '/ok.phar/sub');
 file_put_contents(dirname(__FILE__) . '/oops.phar', '<?php this should screw em up __HALT_COMPILER();');
 mkdir('phar://' . dirname(__FILE__) . '/oops.phar/fails');
 ?>
@@ -57,5 +59,7 @@ Warning: mkdir(): phar error: cannot create directory "phar://%sdir.phar.php/fai
 
 Warning: mkdir(): phar error: cannot create directory "fails" in phar "%sok.phar", directory already exists in %sdir.php on line %d
 
+Warning: mkdir(): phar error: cannot create directory "sub" in phar "%sok.phar", directory already exists in %sdir.php on line %d
+
 Warning: mkdir(): internal corruption of phar "%soops.phar" (truncated manifest at stub end) in %sdir.php on line %d
 ===DONE===
\ No newline at end of file