[PATCH] shell32: handle bad menu handle (Coverity)

Marcus Meissner marcus at jet.franken.de
Sat Jan 9 10:37:22 CST 2010


On Sat, Jan 09, 2010 at 07:18:18PM +0300, Nikolay Sivov wrote:
> On 1/9/2010 16:59, Marcus Meissner wrote:
> >Hi,
> >
> >handle "invalid menu" return -1. Now with test.
> >
> >Ciao, Marcus
> >---
> >  dlls/shell32/shlmenu.c         |    5 +++--
> >  dlls/shell32/tests/shlfileop.c |   13 +++++++++++++
> >  2 files changed, 16 insertions(+), 2 deletions(-)
> >
> 
> >  	{
> >diff --git a/dlls/shell32/tests/shlfileop.c b/dlls/shell32/tests/shlfileop.c
> >index 0a5cdca..4d74b93 100644
> >--- a/dlls/shell32/tests/shlfileop.c
> >+++ b/dlls/shell32/tests/shlfileop.c
> Wrong file to place test in I think.
> >@@ -2224,6 +2224,17 @@ static void test_unicode(void)
> >      ok(!file_existsW(UNICODE_PATH), "The directory should have been removed\n");
> >  }
> >
> >+extern HRESULT WINAPI Shell_MergeMenus (HMENU hmDst, HMENU hmSrc, UINT uInsert, UINT uIDAdjust, UINT uIDAdjustMax, ULONG uFlags);
> >+
> This should got to shlobj.h.
> >+static void
> >+test_shlmenu(void) {
> >+	HRESULT hres;
> >+	hres = Shell_MergeMenus (0, 0, 0x42, 0x4242, 0x424242, 0);
> >+	ok (hres == 0x4242, "expected 0x4242 but got %x\n", hres);
> >+	hres = Shell_MergeMenus ((HMENU)42, 0, 0x42, 0x4242, 0x424242, 0);
> >+	ok (hres == 0x4242, "expected 0x4242 but got %x\n", hres);
> >+}
> >+
> Use a valid empty menu handle here as first parameter. Also I'd like
> to use more sane const values.

Hm. What are valid empty menu handles? 0xffff ?
Or create one? and more sane?

> >  START_TEST(shlfileop)
> >  {
> >      InitFunctionPointers();
> >@@ -2263,4 +2274,6 @@ START_TEST(shlfileop)
> >      clean_after_shfo_tests();
> >
> >      test_unicode();
> >+
> >+    test_shlmenu();
> >  }
> Function is available starting XP SP2 per msdn, so dynamic load
> should be used.

Testbot had no complaints for any version it tests, see 
https://winetestbot.geldorp.nl/JobDetails.pl?Key=279,
but i can change it.

Ciao, Marcus



More information about the wine-devel mailing list