Re: [PHP-CVS] com php-src: check emalloc() result: ext/standard/http_fopen_wrapper.c

[email protected] ("Anatol Belski")
Newsgroups php.cvs,php.internals
Message-ID <[email protected]>
Hi Nikita,

On Sat, September 13, 2014 23:35, Nikita Popov wrote:
> On Sat, Sep 13, 2014 at 11:21 PM, Anatol Belski <[email protected]> wrote:
>
>
>> Commit:    bce562b75efcdacc762a3b94915cdf02056b22dc
>> Author:    Anatol Belski <[email protected]>         Sat, 13 Sep 2014 20:20:17
>> +0200
>> Parents:   e00d48490bbba38a2757b28dfd930dbdf4870331
>> Branches:  master
>>
>>
>> Link:
>> http://git.php.net/?p=php-src.git;a=commitdiff;h=bce562b75efcdacc762a3b9
>> 4915cdf02056b22dc
>>
>>
>> Log:
>> check emalloc() result
>>
>> Changed paths:
>> M  ext/standard/http_fopen_wrapper.c
>>
>>
>>
>> Diff:
>> diff --git a/ext/standard/http_fopen_wrapper.c
>> b/ext/standard/http_fopen_wrapper.c index 45fa637..d7b62e1 100644 ---
>> a/ext/standard/http_fopen_wrapper.c +++
>> b/ext/standard/http_fopen_wrapper.c @@ -587,6 +587,9 @@ finish:
>> /* ensure the header is only sent if user_agent is not
>> blank */ if (ua_len > sizeof(_UA_HEADER)) { ua = emalloc(ua_len + 1); +
>> if (NULL == ua) { +                               return NULL;
>> +                       }
>> if ((ua_len = slprintf(ua, ua_len, _UA_HEADER, ua_str)) > 0) { ua[ua_len]
>> = 0;
>> php_stream_write(stream, ua, ua_len);
>>
>
> emalloc is an infallible allocator, no need to check it for NULL.
>
yeah, it uses the preallocated memory pool. But what when it's out of
memory, was more about that case. Or will it be signaled then? Don't see
currently it would be done.

Regards

Anatol
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.