iliaa                                    Tue, 09 Aug 2011 14:11:56 +0000

Revision: http://svn.php.net/viewvc?view=revision&revision=314653

Log:
Make static analyzers happy

Changed paths:
    U   php/php-src/branches/PHP_5_3/ext/phar/phar_object.c
    U   php/php-src/branches/PHP_5_4/ext/phar/phar_object.c
    U   php/php-src/trunk/ext/phar/phar_object.c

Modified: php/php-src/branches/PHP_5_3/ext/phar/phar_object.c
===================================================================
--- php/php-src/branches/PHP_5_3/ext/phar/phar_object.c 2011-08-09 13:19:21 UTC 
(rev 314652)
+++ php/php-src/branches/PHP_5_3/ext/phar/phar_object.c 2011-08-09 14:11:56 UTC 
(rev 314653)
@@ -1664,11 +1664,14 @@
                                                }

                                                test = expand_filepath(fname, 
NULL TSRMLS_CC);
+                                               efree(fname);

                                                if (test) {
-                                                       efree(fname);
                                                        fname = test;
                                                        fname_len = 
strlen(fname);
+                                               } else {
+                                                       
zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0 TSRMLS_CC, "Could 
not resolve file path");
+                                                       return 
ZEND_HASH_APPLY_STOP;
                                                }

                                                save = fname;
@@ -1694,6 +1697,11 @@
 #else
                                                fname = 
expand_filepath(intern->file_name, NULL TSRMLS_CC);
 #endif
+                                               if (!fname) {
+                                                       
zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0 TSRMLS_CC, "Could 
not resolve file path");
+                                                       return 
ZEND_HASH_APPLY_STOP;
+                                               }
+
                                                fname_len = strlen(fname);
                                                save = fname;
                                                goto phar_spl_fileinfo;
@@ -1711,6 +1719,14 @@
 phar_spl_fileinfo:
        if (base_len) {
                temp = expand_filepath(base, NULL TSRMLS_CC);
+               if (!temp) {
+                       
zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0 TSRMLS_CC, "Could 
not resolve file path");
+                       if (save) {
+                               efree(save);
+                       }
+                       return ZEND_HASH_APPLY_STOP;
+               }
+
                base = temp;
                base_len = strlen(base);

@@ -4083,7 +4099,10 @@
                        if (phar_obj->arc.archive->fp && 
!phar_obj->arc.archive->is_brandnew && !(stub->flags & 
PHAR_ENT_COMPRESSION_MASK)) {
                                fp = phar_obj->arc.archive->fp;
                        } else {
-                               fp = 
php_stream_open_wrapper(phar_obj->arc.archive->fname, "rb", 0, NULL);
+                               if (!(fp = 
php_stream_open_wrapper(phar_obj->arc.archive->fname, "rb", 0, NULL))) {
+                                       
zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0 TSRMLS_CC, "phar 
error: unable to open phar \"%s\"", phar_obj->arc.archive->fname);
+                                       return;
+                               }
                                if (stub->flags & PHAR_ENT_COMPRESSION_MASK) {
                                        char *filter_name;


Modified: php/php-src/branches/PHP_5_4/ext/phar/phar_object.c
===================================================================
--- php/php-src/branches/PHP_5_4/ext/phar/phar_object.c 2011-08-09 13:19:21 UTC 
(rev 314652)
+++ php/php-src/branches/PHP_5_4/ext/phar/phar_object.c 2011-08-09 14:11:56 UTC 
(rev 314653)
@@ -1666,11 +1666,14 @@
                                                }

                                                test = expand_filepath(fname, 
NULL TSRMLS_CC);
+                                               efree(fname);

                                                if (test) {
-                                                       efree(fname);
                                                        fname = test;
                                                        fname_len = 
strlen(fname);
+                                               } else {
+                                                       
zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0 TSRMLS_CC, "Could 
not resolve file path");
+                                                       return 
ZEND_HASH_APPLY_STOP;
                                                }

                                                save = fname;
@@ -1696,6 +1699,11 @@
 #else
                                                fname = 
expand_filepath(intern->file_name, NULL TSRMLS_CC);
 #endif
+                                               if (!fname) {
+                                                       
zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0 TSRMLS_CC, "Could 
not resolve file path");
+                                                       return 
ZEND_HASH_APPLY_STOP;
+                                               }
+
                                                fname_len = strlen(fname);
                                                save = fname;
                                                goto phar_spl_fileinfo;
@@ -1713,6 +1721,14 @@
 phar_spl_fileinfo:
        if (base_len) {
                temp = expand_filepath(base, NULL TSRMLS_CC);
+               if (!temp) {
+                       
zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0 TSRMLS_CC, "Could 
not resolve file path");
+                       if (save) {
+                               efree(save);
+                       }
+                       return ZEND_HASH_APPLY_STOP;
+               }
+
                base = temp;
                base_len = strlen(base);

@@ -4086,7 +4102,10 @@
                        if (phar_obj->arc.archive->fp && 
!phar_obj->arc.archive->is_brandnew && !(stub->flags & 
PHAR_ENT_COMPRESSION_MASK)) {
                                fp = phar_obj->arc.archive->fp;
                        } else {
-                               fp = 
php_stream_open_wrapper(phar_obj->arc.archive->fname, "rb", 0, NULL);
+                               if (!(fp = 
php_stream_open_wrapper(phar_obj->arc.archive->fname, "rb", 0, NULL))) {
+                                       
zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0 TSRMLS_CC, "phar 
error: unable to open phar \"%s\"", phar_obj->arc.archive->fname);
+                                       return;
+                               }
                                if (stub->flags & PHAR_ENT_COMPRESSION_MASK) {
                                        char *filter_name;


Modified: php/php-src/trunk/ext/phar/phar_object.c
===================================================================
--- php/php-src/trunk/ext/phar/phar_object.c    2011-08-09 13:19:21 UTC (rev 
314652)
+++ php/php-src/trunk/ext/phar/phar_object.c    2011-08-09 14:11:56 UTC (rev 
314653)
@@ -1666,11 +1666,14 @@
                                                }

                                                test = expand_filepath(fname, 
NULL TSRMLS_CC);
+                                               efree(fname);

                                                if (test) {
-                                                       efree(fname);
                                                        fname = test;
                                                        fname_len = 
strlen(fname);
+                                               } else {
+                                                       
zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0 TSRMLS_CC, "Could 
not resolve file path");
+                                                       return 
ZEND_HASH_APPLY_STOP;
                                                }

                                                save = fname;
@@ -1696,6 +1699,11 @@
 #else
                                                fname = 
expand_filepath(intern->file_name, NULL TSRMLS_CC);
 #endif
+                                               if (!fname) {
+                                                       
zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0 TSRMLS_CC, "Could 
not resolve file path");
+                                                       return 
ZEND_HASH_APPLY_STOP;
+                                               }
+
                                                fname_len = strlen(fname);
                                                save = fname;
                                                goto phar_spl_fileinfo;
@@ -1713,6 +1721,14 @@
 phar_spl_fileinfo:
        if (base_len) {
                temp = expand_filepath(base, NULL TSRMLS_CC);
+               if (!temp) {
+                       
zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0 TSRMLS_CC, "Could 
not resolve file path");
+                       if (save) {
+                               efree(save);
+                       }
+                       return ZEND_HASH_APPLY_STOP;
+               }
+
                base = temp;
                base_len = strlen(base);

@@ -4086,7 +4102,10 @@
                        if (phar_obj->arc.archive->fp && 
!phar_obj->arc.archive->is_brandnew && !(stub->flags & 
PHAR_ENT_COMPRESSION_MASK)) {
                                fp = phar_obj->arc.archive->fp;
                        } else {
-                               fp = 
php_stream_open_wrapper(phar_obj->arc.archive->fname, "rb", 0, NULL);
+                               if (!(fp = 
php_stream_open_wrapper(phar_obj->arc.archive->fname, "rb", 0, NULL))) {
+                                       
zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0 TSRMLS_CC, "phar 
error: unable to open phar \"%s\"", phar_obj->arc.archive->fname);
+                                       return;
+                               }
                                if (stub->flags & PHAR_ENT_COMPRESSION_MASK) {
                                        char *filter_name;


-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to