From: John Darrington Date: Mon, 13 Apr 2009 23:07:14 +0000 (+0800) Subject: Fixed bug in q2c when munging hyphenated strings. X-Git-Tag: v0.7.3~161 X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?p=pspp-builds.git;a=commitdiff_plain;h=15d25f33d8af81f11ac05379ae267f85da2b3077 Fixed bug in q2c when munging hyphenated strings. Q2c wasn't terminating strings generated by its munge function, resulting in garbage being placed into generated code. Thanks to Michel Boaventura for reporting this. --- diff --git a/src/language/lexer/q2c.c b/src/language/lexer/q2c.c index ea4e3481..be0f29c5 100644 --- a/src/language/lexer/q2c.c +++ b/src/language/lexer/q2c.c @@ -379,7 +379,7 @@ id_cpy (char **cp) static char * unmunge (const char *s) { - char *dest = xmalloc (strlen (s)); + char *dest = xmalloc (strlen (s) + 1); char *d = dest; while (*s) @@ -391,6 +391,7 @@ unmunge (const char *s) s++; d++; } + *d = '\0'; return dest; }