]> granicus.if.org Git - php/commitdiff
MFB: fix crash if stream is empty and reader function sets buffer as null
authorStanislav Malyshev <stas@php.net>
Wed, 12 Sep 2007 21:27:56 +0000 (21:27 +0000)
committerStanislav Malyshev <stas@php.net>
Wed, 12 Sep 2007 21:27:56 +0000 (21:27 +0000)
ext/pdo/pdo_stmt.c

index 0d3fa92dc248a33329e28b2869f83e9405ad7280..9558621593e45a1ba2d80534a8d08227bf4b0090 100755 (executable)
@@ -538,7 +538,11 @@ static inline void fetch_value(pdo_stmt_t *stmt, zval *dest, int colno, int *typ
                                        char *buf = NULL;
                                        size_t len;
                                        len = php_stream_copy_to_mem((php_stream*)value, &buf, PHP_STREAM_COPY_ALL, 0);
-                                       ZVAL_STRINGL(dest, buf, len, 0);
+                                       if(buf == NULL) {
+                                               ZVAL_EMPTY_STRING(dest);
+                                       } else {
+                                               ZVAL_STRINGL(dest, buf, len, 0);
+                                       }
                                        php_stream_close((php_stream*)value);
                                } else {
                                        php_stream_to_zval((php_stream*)value, dest);