From 6c8527c31ca534076ac64df2175dbe971c9d2f52 Mon Sep 17 00:00:00 2001 From: Mike McCormack Date: Mon, 22 Aug 2005 09:19:38 +0000 Subject: [PATCH] - return a precomputed result for a NULL string - pass strlen an LPSTR to eliminate a sign warning --- dlls/ole32/compobj.c | 32 +++++++++++++++++--------------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/dlls/ole32/compobj.c b/dlls/ole32/compobj.c index ea2a17ca99c..52c9c10f75f 100644 --- a/dlls/ole32/compobj.c +++ b/dlls/ole32/compobj.c @@ -813,27 +813,29 @@ HRESULT WINAPI CoCreateGuid(GUID *pguid) */ HRESULT WINAPI __CLSIDFromStringA(LPCSTR idstr, CLSID *id) { - const BYTE *s = (const BYTE *) idstr; + const BYTE *s; int i; BYTE table[256]; - if (!s) - s = "{00000000-0000-0000-0000-000000000000}"; - else { /* validate the CLSID string */ + if (!idstr) { + memset( id, 0, sizeof (CLSID) ); + return S_OK; + } - if (strlen(s) != 38) - return CO_E_CLASSSTRING; + /* validate the CLSID string */ + if (strlen(idstr) != 38) + return CO_E_CLASSSTRING; - if ((s[0]!='{') || (s[9]!='-') || (s[14]!='-') || (s[19]!='-') || (s[24]!='-') || (s[37]!='}')) - return CO_E_CLASSSTRING; + s = (const BYTE *) idstr; + if ((s[0]!='{') || (s[9]!='-') || (s[14]!='-') || (s[19]!='-') || (s[24]!='-') || (s[37]!='}')) + return CO_E_CLASSSTRING; - for (i=1; i<37; i++) { - if ((i == 9)||(i == 14)||(i == 19)||(i == 24)) continue; - if (!(((s[i] >= '0') && (s[i] <= '9')) || - ((s[i] >= 'a') && (s[i] <= 'f')) || - ((s[i] >= 'A') && (s[i] <= 'F')))) - return CO_E_CLASSSTRING; - } + for (i=1; i<37; i++) { + if ((i == 9)||(i == 14)||(i == 19)||(i == 24)) continue; + if (!(((s[i] >= '0') && (s[i] <= '9')) || + ((s[i] >= 'a') && (s[i] <= 'f')) || + ((s[i] >= 'A') && (s[i] <= 'F')))) + return CO_E_CLASSSTRING; } TRACE("%s -> %p\n", s, id);