com php-src: base64_decode: Avoid code duplicatio n in failures: ext/standard/base64.c
| From: | Nikita Popov | Date: | Fri, 22 Jul 2016 16:03:55 +0000 |
| Subject: | com php-src: base64_decode: Avoid code duplicatio n in failures: ext/standard/base64.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-93327@lists.php.net to get a copy of this message | ||
Commit: 0981e5de3c3f46b1be649e2a5bd755cf91d0ef44
Author: Lauri Kenttä <lauri.kentta@gmail.com> Mon, 11 Jul 2016 12:40:05 +0300
Committer: Nikita Popov <nikic@php.net> Fri, 22 Jul 2016 18:03:55 +0200
Parents: 7a02704c0ecdf4373c810760e70a424841619e0c
Branches: PHP-7.1 master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=0981e5de3c3f46b1be649e2a5bd755cf91d0ef44
Log:
base64_decode: Avoid code duplication in failures
Changed paths:
M ext/standard/base64.c
Diff:
diff --git a/ext/standard/base64.c b/ext/standard/base64.c
index d625dc0..fb21759 100644
--- a/ext/standard/base64.c
+++ b/ext/standard/base64.c
@@ -152,8 +152,7 @@ PHPAPI zend_string *php_base64_decode_ex(const unsigned char *str, size_t length
/* fail if the padding character is second in a group (like V===) */
/* FIXME: why do we still allow invalid padding in other places in the middle of the string? */
if (i % 4 == 1) {
- zend_string_free(result);
- return NULL;
+ goto fail;
}
padding++;
continue;
@@ -172,8 +171,7 @@ PHPAPI zend_string *php_base64_decode_ex(const unsigned char *str, size_t length
}
/* fail on bad characters or if any data follows padding */
if (ch == -2 || padding) {
- zend_string_free(result);
- return NULL;
+ goto fail;
}
}
@@ -200,6 +198,10 @@ PHPAPI zend_string *php_base64_decode_ex(const unsigned char *str, size_t
length
ZSTR_VAL(result)[ZSTR_LEN(result)] = '\0';
return result;
+
+fail:
+ zend_string_free(result);
+ return NULL;
}
/* }}} */