summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlan Coopersmith <alan.coopersmith@oracle.com>2018-09-30 14:28:35 -0700
committerAlan Coopersmith <alan.coopersmith@oracle.com>2018-09-30 14:28:35 -0700
commit4512f268c689db62b46c88e813935c66eda14742 (patch)
tree8bfb351268b0cc3fd175697bcc576200bdb6e24c
parentca032d147824861b2451c5b0ff715429f055cfe1 (diff)
When replacing a colormap, free old map, not new one
Found by Oracle's Parfait 2.2 static analyzer: Error: Use after free Use after free [use-after-free] (CWE 416): Use after free of pointer Scr at line 421 of src/util.c in function 'InsertRGBColormap'. Invalid pointer accessible via global Scr at line 105 of src/twm.c maps escapes to sc->maps at line 419 of src/util.c in function 'InsertRGBColormap' maps freed with XFree at line 406 Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
-rw-r--r--src/util.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/util.c b/src/util.c
index 8e9dab9..e254cd5 100644
--- a/src/util.c
+++ b/src/util.c
@@ -403,7 +403,7 @@ InsertRGBColormap (Atom a, XStandardColormap *maps, int nmaps, Bool replace)
}
if (replace) { /* just update contents */
- if (sc->maps) XFree (maps);
+ if (sc->maps) XFree (sc->maps);
if (sc == Scr->StdCmapInfo.mru) Scr->StdCmapInfo.mru = NULL;
} else { /* else appending */
sc->next = NULL;