Re: [PATCH] Fix null pointer dereference(s) --

From: Date: Fri, 16 Jan 2015 08:30:09 +0000
Subject: Re: [PATCH] Fix null pointer dereference(s) --
References: 1 2  Groups: php.internals 
Request: Send a blank email to internals+get-80625@lists.php.net to get a copy of this message
On 16/01/15 19:23, Stanislav Malyshev wrote: > No C++ comments please. Fixed.(Will push afterwards) >> > if (buf.c) { >> > - *pbuf = buf.c; >> > + if(pbuf) { >> > + *pbuf = buf.c; >> > + } >> > result = buf.len; > I think if pbuf is null, it should return 0 immediately. The code you > provided would result in a memory leak if pbuf is NULL, since the > pointer to buf.c would be lost as soon as vspprintf exits. So, at the start of the code, have if(!pbuf) { return 0; }? i.e; --snip-- PHPAPI size_t vspprintf(char **pbuf, size_t max_len, const char *format, va_list ap) /* {{{ */ { if(!pbuf) { return 0; } smart_string buf = {0}; size_t result; xbuf_format_converter(&buf, 1, format, ap); --snip-- ? Let me know. Thanks, -- -- Joshua Rogers <https://internot.info/>

Attachment: [application/pgp-signature] OpenPGP digital signature signature.asc
« previous php.internals (#80625) next »