cp_unqoute(), avoid segfault when applied to a single quote "\""

This commit is contained in:
rlar
2010-09-19 14:09:12 +00:00
parent 83da42e3bf
commit d76862055e
2 changed files with 13 additions and 2 deletions
+1 -1
View File
@@ -81,7 +81,7 @@ cp_unquote(char *string)
l = strlen(string);
s = (char*) MALLOC(l+1);
if (*string == '"' && string[l-1] == '"') {
if (l>=2 && *string == '"' && string[l-1] == '"') {
strncpy(s,string+1,l-2);
s[l-2] = '\0';
} else