Thread (12 messages) 12 messages, 4 authors, 2022-08-01
STALE1438d
Revisions (3)
  1. v1 [diff vs current]
  2. v2 current
  3. v2 [diff vs current]

[PATCH 1/5 v2] parse_layout_faulty: fix memleak

From: Wu Guanghao <hidden>
Date: 2022-06-09 03:06:21
Subsystem: the rest · Maintainer: Linus Torvalds

char *m is allocated by xstrdup but not free() before return, will cause
a memory leak.

Signed-off-by: Wu Guanghao <redacted>
---
 util.c | 3 +++
 1 file changed, 3 insertions(+)
diff --git a/util.c b/util.c
index cc94f96e..46b04afb 100644
--- a/util.c
+++ b/util.c
@@ -427,8 +427,11 @@ int parse_layout_faulty(char *layout)
        int ln = strcspn(layout, "0123456789");
        char *m = xstrdup(layout);
        int mode;
+
        m[ln] = 0;
        mode = map_name(faultylayout, m);
+       free(m);
+
        if (mode == UnSet)
                return -1;

--
2.27.0
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help