From 3b8b8a20d24ab509540b314e751b47d02922fc6b Mon Sep 17 00:00:00 2001 From: Werner Almesberger Date: Sun, 7 Aug 2016 16:03:13 -0300 Subject: [PATCH] eeshow/lib-parse.c (parse_def): don't break free'ing the component name --- eeshow/lib-parse.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/eeshow/lib-parse.c b/eeshow/lib-parse.c index 00a8854..379458b 100644 --- a/eeshow/lib-parse.c +++ b/eeshow/lib-parse.c @@ -69,8 +69,14 @@ static bool parse_def(struct lib *lib, const char *line) return 0; lib->curr_comp = alloc_type(struct comp); - if (*s == '~') - s++; + if (*s == '~') { + char *tmp = alloc_size(strlen(s) + 1); + + /* we can't just s++, since that would break freeing */ + strcpy(tmp, s + 1); + free(s); + s = tmp; + } lib->curr_comp->name = s; lib->curr_comp->units = units;