mirror of
https://github.com/brl/mutter.git
synced 2024-11-22 16:10:41 -05:00
monitor-manager-xrandr: Fix small leak for invalid properties
If the property is invalid, then we leak the allocated buffer. Make sure to free it in this case.
This commit is contained in:
parent
68283df4d9
commit
21bffe4aef
@ -144,7 +144,7 @@ static gboolean
|
|||||||
output_get_boolean_property (MetaMonitorManagerXrandr *manager_xrandr,
|
output_get_boolean_property (MetaMonitorManagerXrandr *manager_xrandr,
|
||||||
MetaOutput *output, const char *propname)
|
MetaOutput *output, const char *propname)
|
||||||
{
|
{
|
||||||
gboolean value;
|
gboolean value = FALSE;
|
||||||
Atom atom, actual_type;
|
Atom atom, actual_type;
|
||||||
int actual_format;
|
int actual_format;
|
||||||
unsigned long nitems, bytes_after;
|
unsigned long nitems, bytes_after;
|
||||||
@ -158,12 +158,12 @@ output_get_boolean_property (MetaMonitorManagerXrandr *manager_xrandr,
|
|||||||
&actual_type, &actual_format,
|
&actual_type, &actual_format,
|
||||||
&nitems, &bytes_after, &buffer);
|
&nitems, &bytes_after, &buffer);
|
||||||
|
|
||||||
if (actual_type != XA_CARDINAL || actual_format != 32 ||
|
if (actual_type != XA_CARDINAL || actual_format != 32 || nitems < 1)
|
||||||
nitems < 1)
|
goto out;
|
||||||
return FALSE;
|
|
||||||
|
|
||||||
value = ((int*)buffer)[0];
|
value = ((int*)buffer)[0];
|
||||||
|
|
||||||
|
out:
|
||||||
XFree (buffer);
|
XFree (buffer);
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
@ -187,7 +187,7 @@ static int
|
|||||||
output_get_backlight_xrandr (MetaMonitorManagerXrandr *manager_xrandr,
|
output_get_backlight_xrandr (MetaMonitorManagerXrandr *manager_xrandr,
|
||||||
MetaOutput *output)
|
MetaOutput *output)
|
||||||
{
|
{
|
||||||
gboolean value;
|
int value = -1;
|
||||||
Atom atom, actual_type;
|
Atom atom, actual_type;
|
||||||
int actual_format;
|
int actual_format;
|
||||||
unsigned long nitems, bytes_after;
|
unsigned long nitems, bytes_after;
|
||||||
@ -201,14 +201,17 @@ output_get_backlight_xrandr (MetaMonitorManagerXrandr *manager_xrandr,
|
|||||||
&actual_type, &actual_format,
|
&actual_type, &actual_format,
|
||||||
&nitems, &bytes_after, &buffer);
|
&nitems, &bytes_after, &buffer);
|
||||||
|
|
||||||
if (actual_type != XA_INTEGER || actual_format != 32 ||
|
if (actual_type != XA_INTEGER || actual_format != 32 || nitems < 1)
|
||||||
nitems < 1)
|
goto out;
|
||||||
return -1;
|
|
||||||
|
|
||||||
value = ((int*)buffer)[0];
|
value = ((int*)buffer)[0];
|
||||||
|
|
||||||
|
out:
|
||||||
XFree (buffer);
|
XFree (buffer);
|
||||||
|
if (value > 0)
|
||||||
return normalize_backlight (output, value);
|
return normalize_backlight (output, value);
|
||||||
|
else
|
||||||
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
Loading…
Reference in New Issue
Block a user