[PATCH v2 2/2] advapi32: Don't read the key name if the root key handle is invalid

Alex Henrie alexhenrie24 at gmail.com
Thu Nov 8 10:21:09 CST 2018


On Wed, Nov 7, 2018 at 11:57 PM Alexandre Julliard <julliard at winehq.org> wrote:
>
> Alex Henrie <alexhenrie24 at gmail.com> writes:
>
> > On Wed, Nov 7, 2018 at 9:11 AM Alexandre Julliard <julliard at winehq.org> wrote:
> >>
> >> Alex Henrie <alexhenrie24 at gmail.com> writes:
> >>
> >> > Signed-off-by: Alex Henrie <alexhenrie24 at gmail.com>
> >> > ---
> >> >  dlls/advapi32/registry.c       | 2 ++
> >> >  dlls/advapi32/tests/registry.c | 6 ++++++
> >> >  2 files changed, 8 insertions(+)
> >> >
> >> > diff --git a/dlls/advapi32/registry.c b/dlls/advapi32/registry.c
> >> > index 0a8ccfbf20..4b33ade88c 100644
> >> > --- a/dlls/advapi32/registry.c
> >> > +++ b/dlls/advapi32/registry.c
> >> > @@ -313,6 +313,8 @@ static inline HKEY get_special_root_hkey( HKEY hkey, REGSAM access )
> >> >  {
> >> >      HKEY ret = hkey;
> >> >
> >> > +    if (hkey == INVALID_HANDLE_VALUE) return 0;
> >>
> >> There shouldn't be any reason to check for INVALID_HANDLE_VALUE, it
> >> doesn't have a special meaning. I expect you'll get the same behavior
> >> with any other invalid handle.
> >
> > Is there a straightforward way to check whether the handle is valid?
>
> You shouldn't need to add explicit checks, it should fall off from the
> normal function behavior. That's probably true for your other patch too.

Leaving aside the second patch for the moment, the tests show that
RegCreateKeyEx[AW] checks the retkey parameter before checking the
hkey parameter. If you don't want retkey to be explicitly checked at
the beginning of RegCreateKeyEx[AW], how do you want the check to be
done?

-Alex



More information about the wine-devel mailing list