Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
Browse files

Fixed bug 1736 - Memory leak in X11_InitModes

tomaszewski.p

XRRListOutputProperties allocates Atom* array, which is not freed.
XRRGetOutputProperty allocates 'unsigned char *prop' array, which is not freed.
  • Loading branch information
slouken committed Mar 1, 2013
1 parent 7acd949 commit 25944df5cfd9e9f146e7b778923bde0f0612e4f4
Showing with 20 additions and 15 deletions.
  1. +20 −15 src/video/x11/SDL_x11modes.c
@@ -576,26 +576,31 @@ X11_InitModes(_THIS)
int actual_format;
unsigned long nitems, bytes_after;
Atom actual_type;

if (props[i] == EDID) {
XRRGetOutputProperty(data->display, res->outputs[output], props[i],
0, 100, False, False,
AnyPropertyType,
&actual_type, &actual_format,
&nitems, &bytes_after, &prop);

MonitorInfo *info = decode_edid(prop);
if (info) {
#ifdef X11MODES_DEBUG
printf("Found EDID data for %s\n", output_info->name);
dump_monitor_info(info);
#endif
SDL_strlcpy(display_name, info->dsc_product_name, sizeof(display_name));
free(info);
if (XRRGetOutputProperty(data->display,
res->outputs[output], props[i],
0, 100, False, False,
AnyPropertyType,
&actual_type, &actual_format,
&nitems, &bytes_after, &prop) == Success ) {
MonitorInfo *info = decode_edid(prop);
if (info) {
#ifdef X11MODES_DEBUG
printf("Found EDID data for %s\n", output_info->name);
dump_monitor_info(info);
#endif
SDL_strlcpy(display_name, info->dsc_product_name, sizeof(display_name));
free(info);
}
SDL_free(prop);
}
break;
}
}
if (props) {
SDL_free(props);
}

if (*display_name && inches) {
size_t len = SDL_strlen(display_name);

0 comments on commit 25944df

Please sign in to comment.