]> granicus.if.org Git - php/commitdiff
fix leak
authorAntony Dovgal <tony2001@php.net>
Fri, 23 Feb 2007 20:50:17 +0000 (20:50 +0000)
committerAntony Dovgal <tony2001@php.net>
Fri, 23 Feb 2007 20:50:17 +0000 (20:50 +0000)
no need to allocate the buffer if there was no data

ext/curl/interface.c

index dfeebe43e05a6bd805b02cd00d8074afff9f1ff8..faba70a1dddab0b1af5ac09ec23df612ab2ac918 100644 (file)
@@ -713,7 +713,9 @@ static size_t curl_write(char *data, size_t size, size_t nmemb, void *ctx)
                case PHP_CURL_FILE:
                        return fwrite(data, size, nmemb, t->fp);
                case PHP_CURL_RETURN:
-                       smart_str_appendl(&t->buf, data, (int) length);
+                       if (length > 0) {
+                               smart_str_appendl(&t->buf, data, (int) length);
+                       }
                        break;
                case PHP_CURL_USER: {
                        zval **argv[2];
@@ -852,7 +854,7 @@ static size_t curl_write_header(char *data, size_t size, size_t nmemb, void *ctx
                case PHP_CURL_STDOUT:
                        /* Handle special case write when we're returning the entire transfer
                         */
-                       if (ch->handlers->write->method == PHP_CURL_RETURN) {
+                       if (ch->handlers->write->method == PHP_CURL_RETURN && length > 0) {
                                smart_str_appendl(&ch->handlers->write->buf, data, (int) length);
                        } else {
                                PHPWRITE(data, length);