st/theme-node: Fix potential NULL pointer dereferences
If the new CSS functions added in commitc593aecbde
are used wrongly, an expected argument may be missing. The code checks for that, but only after dereferencing it to assign the next argument. Fix that by splitting up the checks. Spotted by coverity. CID: #462818 Fixes:c593aecbde
("st/theme-node: Implement extensions for accent color") Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/3380>
This commit is contained in:
@ -617,13 +617,17 @@ get_color_from_transparentize_term (StThemeNode *node,
|
|||||||
CRTerm *term,
|
CRTerm *term,
|
||||||
CoglColor *color)
|
CoglColor *color)
|
||||||
{
|
{
|
||||||
CRTerm *color_arg = term->ext_content.func_param;
|
CRTerm *color_arg, *amount_arg;
|
||||||
CRTerm *amount_arg = color_arg->next;
|
|
||||||
CoglColor base_color;
|
CoglColor base_color;
|
||||||
CRNum *amount_num;
|
CRNum *amount_num;
|
||||||
double amount;
|
double amount;
|
||||||
|
|
||||||
if (!color_arg || !amount_arg)
|
color_arg = term->ext_content.func_param;
|
||||||
|
if (!color_arg)
|
||||||
|
return VALUE_NOT_FOUND;
|
||||||
|
|
||||||
|
amount_arg = color_arg->next;
|
||||||
|
if (!amount_arg)
|
||||||
return VALUE_NOT_FOUND;
|
return VALUE_NOT_FOUND;
|
||||||
|
|
||||||
if (get_color_from_term (node, color_arg, &base_color) != VALUE_FOUND)
|
if (get_color_from_term (node, color_arg, &base_color) != VALUE_FOUND)
|
||||||
@ -656,14 +660,21 @@ get_color_from_mix_term (StThemeNode *node,
|
|||||||
CRTerm *term,
|
CRTerm *term,
|
||||||
CoglColor *color)
|
CoglColor *color)
|
||||||
{
|
{
|
||||||
CRTerm *color1_arg = term->ext_content.func_param;
|
CRTerm *color1_arg, *color2_arg, *factor_arg;
|
||||||
CRTerm *color2_arg = color1_arg->next;
|
|
||||||
CRTerm *factor_arg = color2_arg->next;
|
|
||||||
CoglColor color1, color2;
|
CoglColor color1, color2;
|
||||||
CRNum *factor_num;
|
CRNum *factor_num;
|
||||||
double factor;
|
double factor;
|
||||||
|
|
||||||
if (!color1_arg || !color2_arg || !factor_arg)
|
color1_arg = term->ext_content.func_param;
|
||||||
|
if (!color1_arg)
|
||||||
|
return VALUE_NOT_FOUND;
|
||||||
|
|
||||||
|
color2_arg = color1_arg->next;
|
||||||
|
if (!color2_arg)
|
||||||
|
return VALUE_NOT_FOUND;
|
||||||
|
|
||||||
|
factor_arg = color2_arg->next;
|
||||||
|
if (!factor_arg)
|
||||||
return VALUE_NOT_FOUND;
|
return VALUE_NOT_FOUND;
|
||||||
|
|
||||||
if (get_color_from_term (node, color1_arg, &color1) != VALUE_FOUND ||
|
if (get_color_from_term (node, color1_arg, &color1) != VALUE_FOUND ||
|
||||||
@ -706,14 +717,18 @@ get_color_from_lighten_term (StThemeNode *node,
|
|||||||
CRTerm *term,
|
CRTerm *term,
|
||||||
CoglColor *color)
|
CoglColor *color)
|
||||||
{
|
{
|
||||||
CRTerm *color_arg = term->ext_content.func_param;
|
CRTerm *color_arg, *factor_arg;
|
||||||
CRTerm *factor_arg = color_arg->next;
|
|
||||||
CoglColor base_color;
|
CoglColor base_color;
|
||||||
CRNum *factor_num;
|
CRNum *factor_num;
|
||||||
double factor;
|
double factor;
|
||||||
float hue, luminance, saturation;
|
float hue, luminance, saturation;
|
||||||
|
|
||||||
if (!color_arg || !factor_arg)
|
color_arg = term->ext_content.func_param;
|
||||||
|
if (!color_arg)
|
||||||
|
return VALUE_NOT_FOUND;
|
||||||
|
|
||||||
|
factor_arg = color_arg->next;
|
||||||
|
if (!factor_arg)
|
||||||
return VALUE_NOT_FOUND;
|
return VALUE_NOT_FOUND;
|
||||||
|
|
||||||
if (get_color_from_term (node, color_arg, &base_color) != VALUE_FOUND)
|
if (get_color_from_term (node, color_arg, &base_color) != VALUE_FOUND)
|
||||||
@ -746,14 +761,18 @@ get_color_from_darken_term (StThemeNode *node,
|
|||||||
CRTerm *term,
|
CRTerm *term,
|
||||||
CoglColor *color)
|
CoglColor *color)
|
||||||
{
|
{
|
||||||
CRTerm *color_arg = term->ext_content.func_param;
|
CRTerm *color_arg, *factor_arg;
|
||||||
CRTerm *factor_arg = color_arg->next;
|
|
||||||
CoglColor base_color;
|
CoglColor base_color;
|
||||||
CRNum *factor_num;
|
CRNum *factor_num;
|
||||||
double factor;
|
double factor;
|
||||||
float hue, luminance, saturation;
|
float hue, luminance, saturation;
|
||||||
|
|
||||||
if (!color_arg || !factor_arg)
|
color_arg = term->ext_content.func_param;
|
||||||
|
if (!color_arg)
|
||||||
|
return VALUE_NOT_FOUND;
|
||||||
|
|
||||||
|
factor_arg = color_arg->next;
|
||||||
|
if (!factor_arg)
|
||||||
return VALUE_NOT_FOUND;
|
return VALUE_NOT_FOUND;
|
||||||
|
|
||||||
if (get_color_from_term (node, color_arg, &base_color) != VALUE_FOUND)
|
if (get_color_from_term (node, color_arg, &base_color) != VALUE_FOUND)
|
||||||
|
Reference in New Issue
Block a user