com php-src: Merge branch 'PHP-5.6': main/spprintf.c
| From: | Stanislav Malyshev | Date: | Tue, 20 Jan 2015 19:47:46 +0000 |
| Subject: | com php-src: Merge branch 'PHP-5.6': main/spprintf.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-84218@lists.php.net to get a copy of this message | ||
Commit: 65aba8bd71428135a5a94062bc106c9929a4fc76
Author: Stanislav Malyshev <stas@php.net> Tue, 20 Jan 2015 11:47:46 -0800
Parents: b16fdebcf8f59e5aa09c11782c05224762ca835e c9162147f23426dbe0a35c755cadd172aab5dae1
Branches: master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=65aba8bd71428135a5a94062bc106c9929a4fc76
Log:
Merge branch 'PHP-5.6'
* PHP-5.6:
add protection against nulls
Conflicts:
main/spprintf.c
Changed paths:
MM main/spprintf.c
Diff:
diff --cc main/spprintf.c
index cd14882,56ffe51..322ea60
--- a/main/spprintf.c
+++ b/main/spprintf.c
@@@ -835,28 -809,25 +835,33 @@@ skip_output
/*
* This is the general purpose conversion function.
*/
-PHPAPI int vspprintf(char **pbuf, size_t max_len, const char *format, va_list ap) /* {{{ */
+PHPAPI size_t vspprintf(char **pbuf, size_t max_len, const char *format, va_list ap) /* {{{ */
{
- smart_str xbuf = {0};
+ smart_string buf = {0};
+ size_t result;
+ /* since there are places where (v)spprintf called without checking for null,
+ a bit of defensive coding here */
+ if(!pbuf) {
+ return 0;
+ }
- xbuf_format_converter(&xbuf, format, ap);
+ xbuf_format_converter(&buf, 1, format, ap);
- if (max_len && xbuf.len > max_len) {
- xbuf.len = max_len;
+ if (max_len && buf.len > max_len) {
+ buf.len = max_len;
}
- smart_str_0(&xbuf);
- *pbuf = xbuf.c;
+ smart_string_0(&buf);
+
+ if (buf.c) {
+ *pbuf = buf.c;
+ result = buf.len;
+ } else {
+ *pbuf = NULL;
+ result = 0;
+ }
- return xbuf.len;
+ return result;
}
/* }}} */