}
/* }}} */
-static zval *phar_rename_archive(phar_archive_data *phar, char *ext, zend_bool compress TSRMLS_DC) /* {{{ */
+static zval *phar_rename_archive(phar_archive_data **sphar, char *ext, zend_bool compress TSRMLS_DC) /* {{{ */
{
const char *oldname = NULL;
+ phar_archive_data *phar = *sphar;
char *oldpath = NULL;
char *basename = NULL, *basepath = NULL;
char *newname = NULL, *newpath = NULL;
phar->fp = NULL;
phar_destroy_phar_data(phar TSRMLS_CC);
phar = *pphar;
+ *sphar = NULL;
phar->refcount++;
newpath = oldpath;
goto its_ok;
phar_add_virtual_dirs(phar, newentry.filename, newentry.filename_len TSRMLS_CC);
}
- if ((ret = phar_rename_archive(phar, ext, 0 TSRMLS_CC))) {
+ if ((ret = phar_rename_archive(&phar, ext, 0 TSRMLS_CC))) {
return ret;
} else {
- zend_hash_destroy(&(phar->manifest));
- zend_hash_destroy(&(phar->mounted_dirs));
- zend_hash_destroy(&(phar->virtual_dirs));
- if (phar->fp) {
- php_stream_close(phar->fp);
+ if(phar != NULL) {
+ zend_hash_destroy(&(phar->manifest));
+ zend_hash_destroy(&(phar->mounted_dirs));
+ zend_hash_destroy(&(phar->virtual_dirs));
+ if (phar->fp) {
+ php_stream_close(phar->fp);
+ }
+ efree(phar->fname);
+ efree(phar);
}
- efree(phar->fname);
- efree(phar);
return NULL;
}
}