fixed memory leak in colour parsing code

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@10262 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2001-05-21 23:22:26 +00:00
parent 7561aacd5e
commit c48269b9f7

View File

@@ -561,11 +561,15 @@ static bool GetRGBFromName(const char *inname, bool *isNone,
grey[2] = 'a'; grey[2] = 'a';
// check for special 'none' colour: // check for special 'none' colour:
bool found;
if ( strcmp(name, "none") == 0 ) if ( strcmp(name, "none") == 0 )
{ {
*isNone = TRUE; *isNone = TRUE;
return TRUE; found = TRUE;
} }
else // not "None"
{
found = FALSE;
// binary search: // binary search:
left = 0; left = 0;
@@ -581,21 +585,23 @@ static bool GetRGBFromName(const char *inname, bool *isNone,
*g = (unsigned char)((rgbVal >> 8) & 0xFF); *g = (unsigned char)((rgbVal >> 8) & 0xFF);
*b = (unsigned char)((rgbVal) & 0xFF); *b = (unsigned char)((rgbVal) & 0xFF);
*isNone = FALSE; *isNone = FALSE;
free(name); found = TRUE;
return TRUE; break;
} }
else if ( cmp < 0 ) else if ( cmp < 0 )
{ {
right = middle - 1; right = middle - 1;
} }
else else // cmp > 0
{ // > 0 {
left = middle + 1; left = middle + 1;
} }
} while (left <= right); } while (left <= right);
}
free(name); free(name);
return FALSE;
return found;
} }
static const char *ParseColor(const char *data) static const char *ParseColor(const char *data)