comctl32: realloc or free and alloc

Alexey Fisher bug-track at fisher-privat.net
Sun May 1 00:43:24 CDT 2011


Am Samstag, den 30.04.2011, 14:41 +0000 schrieb Dan Kegel:
> Alexey wrote:
> 
> > i currently digg in comctl32 to find why my app fails. I found that
> > string conversation AtoW in some places silently fails. The problem is
> > that the destination for string is just a fresh pointer (not NULL).
> > Str_SetPtrAtoW check if it is NULL pointer and if not it trys to
> > ReAlloc. There was no Alloc before so ReAlloc returns NULL
> 
> The code looks like it assumes that pointer is always
> managed by Alloc/ReAlloc/Free.  In what context is
> the destination a fresh, non-Alloc'd pointer?
> Perhaps that's where the bug lies.

We do not need to save anything what was in the target. Even the old
code ReAloocate it and then rewrite. In most contexts the pointer is a
fresh one. If it is not, it should be freed before this func.

> Your proposed solution would pass a non-Alloc'd
> pointer to Free, which doesn't seem good.

So probably best solution is to forbid using not a NULL pointer in this
func. The programmer should decide where to Free it before.




More information about the wine-devel mailing list