]> granicus.if.org Git - php/commitdiff
MFB: Fixed a possible crash when phar_create_signature() fails
authorIlia Alshanetsky <iliaa@php.net>
Fri, 2 Jan 2009 20:43:58 +0000 (20:43 +0000)
committerIlia Alshanetsky <iliaa@php.net>
Fri, 2 Jan 2009 20:43:58 +0000 (20:43 +0000)
ext/phar/phar.c

index 20c17fe1c6750abf1e4c3f5fe71edb7d8d306ea2..177ab8f32f9e64c3d46bd25ad86628b0bf4a7042 100644 (file)
@@ -3122,7 +3122,7 @@ int phar_flush(phar_archive_data *phar, char *user_stub, long len, int convert,
                                return EOF;
 #endif
                        default: {
-                               char *digest;
+                               char *digest = NULL;
                                int digest_len;
 
                                if (FAILURE == phar_create_signature(phar, newfile, &digest, &digest_len, error TSRMLS_CC)) {
@@ -3131,7 +3131,9 @@ int phar_flush(phar_archive_data *phar, char *user_stub, long len, int convert,
                                                spprintf(error, 0, "phar error: unable to write signature: %s", save);
                                                efree(save);
                                        }
-                                       efree(digest);
+                                       if (digest) {
+                                               efree(digest);
+                                       }
                                        if (closeoldfile) {
                                                php_stream_close(oldfile);
                                        }