Re: [PATCH] Fix null pointer dereference(s) --
| From: | Stanislav Malyshev | Date: | Fri, 16 Jan 2015 08:23:59 +0000 |
| Subject: | Re: [PATCH] Fix null pointer dereference(s) -- | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-80624@lists.php.net to get a copy of this message | ||
Hi!
> + //Test 'pbuf'(also known as 'error') against NULL, since it is called
> multiple places without checking against, causing null pointer dereferences.
No C++ comments please.
> 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.
--
Stas Malyshev
smalyshev@gmail.com