Commit 6c8527c3 authored by Mike McCormack's avatar Mike McCormack Committed by Alexandre Julliard

- return a precomputed result for a NULL string

- pass strlen an LPSTR to eliminate a sign warning
parent 6bb46e31
......@@ -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);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment