[PATCH v2] quartz: Don't call memcpy with src=0 in FM2_WriteFilterData (Coverity)

Alex Henrie alexhenrie24 at gmail.com
Tue Aug 14 09:53:23 CDT 2018


On Tue, Aug 14, 2018 at 7:46 AM Andrew Eikum <aeikum at codeweavers.com> wrote:
>
> On Mon, Aug 13, 2018 at 04:33:21PM -0600, Alex Henrie wrote:
> > Signed-off-by: Alex Henrie <alexhenrie24 at gmail.com>
> > ---
> > Passing NULL to memcpy causes a segfault in newer versions of GCC, see
> > https://www.imperialviolet.org/2016/06/26/nonnull.html
> >
> > v2: Fixed email address
> > ---
> >  dlls/quartz/filtermapper.c | 7 +++++--
> >  1 file changed, 5 insertions(+), 2 deletions(-)
> >
> > diff --git a/dlls/quartz/filtermapper.c b/dlls/quartz/filtermapper.c
> > index 0d26198637..7a5b5aee72 100644
> > --- a/dlls/quartz/filtermapper.c
> > +++ b/dlls/quartz/filtermapper.c
> > @@ -148,8 +148,11 @@ static int add_data(struct Vector * v, const BYTE * pData, int size)
> >          LPBYTE pOldData = v->pData;
> >          v->capacity = (v->capacity + size) * 2;
> >          v->pData = CoTaskMemAlloc(v->capacity);
> > -        memcpy(v->pData, pOldData, v->current);
> > -        CoTaskMemFree(pOldData);
> > +        if (pOldData)
> > +        {
> > +            memcpy(v->pData, pOldData, v->current);
> > +            CoTaskMemFree(pOldData);
> > +        }
>
> Could all this logic be replaced by CoTaskMemRealloc?

Good point. I don't see why not.

-Alex



More information about the wine-devel mailing list