summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorUli Schlachter <psychon@znc.in>2013-09-19 17:47:22 +0200
committerMichael Stapelberg <michael@stapelberg.de>2013-09-20 06:19:04 +0200
commit8f3279a2b3711b6f311c5a31d77c6a8c05c4c3ac (patch)
tree77256a562137130272c4dce6be7e9b756baecefc
parent021c7b741d94d776948774f576c71a40ba8a932a (diff)
Fix memleak with broken resource databases
If someone e.g. defines Xcursor.theme twice in the resource information, this would cause c->rm[RM_XCURSOR_THEME] to be set via strdup() twice which means that the first pointer is leaked. Fix this by freeing the old value in this case. Signed-off-by: Uli Schlachter <psychon@znc.in>
-rw-r--r--cursor/cursor.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/cursor/cursor.c b/cursor/cursor.c
index 24999e0..fd75ba9 100644
--- a/cursor/cursor.c
+++ b/cursor/cursor.c
@@ -73,12 +73,16 @@ static void parse_resource_manager(xcb_cursor_context_t *c, const xcb_get_proper
sep++;
/* strdup() may return NULL, which is interpreted later as the key not
* being available. */
- if (strcmp(line, "Xcursor.theme") == 0)
+ if (strcmp(line, "Xcursor.theme") == 0) {
+ free(c->rm[RM_XCURSOR_THEME]);
c->rm[RM_XCURSOR_THEME] = strdup(sep);
- else if (strcmp(line, "Xcursor.size") == 0)
+ } else if (strcmp(line, "Xcursor.size") == 0) {
+ free(c->rm[RM_XCURSOR_SIZE]);
c->rm[RM_XCURSOR_SIZE] = strdup(sep);
- else if (strcmp(line, "Xft.dpi") == 0)
+ } else if (strcmp(line, "Xft.dpi") == 0) {
+ free(c->rm[RM_XFT_DPI]);
c->rm[RM_XFT_DPI] = strdup(sep);
+ }
}
free(rm);