Commit f94273e2 authored by Alan Coopersmith's avatar Alan Coopersmith

Add some missing allocation failure checks in src/xcms

Signed-off-by: Alan Coopersmith's avatarAlan Coopersmith <alan.coopersmith@oracle.com>
parent 76850471
......@@ -798,6 +798,8 @@ XcmsConvertColors(
*/
if (nColors > 1) {
pColors_tmp = Xmallocarray(nColors, sizeof(XcmsColor));
if (pColors_tmp == NULL)
return(XcmsFailure);
} else {
pColors_tmp = &Color1;
}
......
......@@ -87,6 +87,8 @@ XcmsStoreColors(
*/
if (nColors > 1) {
pColors_tmp = Xmallocarray(nColors, sizeof(XcmsColor));
if (pColors_tmp == NULL)
return(XcmsFailure);
} else {
pColors_tmp = &Color1;
}
......
......@@ -210,6 +210,8 @@ _XcmsParseColorString(
*/
if ((len = strlen(color_string)) >= sizeof(string_buf)) {
string_lowered = Xmalloc(len+1);
if (string_lowered == NULL)
return(XcmsFailure);
} else {
string_lowered = string_buf;
}
......@@ -419,6 +421,8 @@ _XcmsLookupColorName(
Retry:
if ((len = strlen(tmpName)) > 63) {
name_lowered = Xmalloc(len+1);
if (name_lowered == NULL)
return(XcmsFailure);
} else {
name_lowered = name_lowered_64;
}
......@@ -762,6 +766,13 @@ LoadColornameDB(void)
strings = Xmalloc(size);
pairs = Xcalloc(nEntries, sizeof(XcmsPair));
if (strings == NULL || pairs == NULL) {
free(strings);
free(pairs);
(void) fclose(stream);
XcmsColorDbState = XcmsDbInitFailure;
return(XcmsFailure);
}
ReadColornameDB(stream, pairs, strings);
(void) fclose(stream);
......
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