ntdll: fix uninitialized buffers, found via valgrind
Dan Hipschman
dsh at linux.ucla.edu
Wed Nov 21 18:56:33 CST 2007
On Wed, Nov 21, 2007 at 06:53:27PM -0600, James Hawkins wrote:
> On Nov 21, 2007 6:08 PM, Zac Brown <zac at zacbrown.org> wrote:
> > Hi,
> >
> > Fixes valgrind error:
> > http://kegel.com/wine/valgrind/20071121/vg-ntdll_env.txt
> >
> > Changelog:
> > * Initialize buffers used in test using memset
> >
> > --
> > Zac Brown <zac AT zacbrown DOT org>
> >
> >
> > dlls/ntdll/tests/env.c | 7 +++++--
> > 1 files changed, 5 insertions(+), 2 deletions(-)
> >
> > diff --git a/dlls/ntdll/tests/env.c b/dlls/ntdll/tests/env.c
> > index d822946..90a3bf1 100644
> > --- a/dlls/ntdll/tests/env.c
> > +++ b/dlls/ntdll/tests/env.c
> > @@ -80,8 +80,7 @@ static void testQuery(void)
> > {NULL, 0, 0, NULL}
> > };
> >
> > - WCHAR bn[257];
> > - WCHAR bv[257];
> > +
> > UNICODE_STRING name;
> > UNICODE_STRING value;
> > const struct test* test;
> > @@ -89,6 +88,10 @@ static void testQuery(void)
> >
> > for (test = tests; test->var; test++)
> > {
> > + WCHAR bn[257];
> > + WCHAR bv[257];
> > + memset(bn, '\0', 257 * sizeof(WCHAR));
> > + memset(bv, '\0', 257 * sizeof(WCHAR));
> > name.Length = strlen(test->var) * 2;
> > name.MaximumLength = name.Length + 2;
> > name.Buffer = bn;
> >
>
> Why did you move the variable declaration? Also, please don't use
> magic constants; sizeof(bn) *sizeof(WCHAR) is what you want.
Just sizeof bn.
More information about the wine-devel
mailing list