diff input/input.c @ 10624:cdfd4a43c406

I've juste found a bug which prevent to load a file whose name contain a quote ('). The menu simply execute a "loadfile '%p'" but when the %p is replaced by the actual value, quotes in it are not escaped ! Moreover, mp_input_parse_cmd contain some code to unescape strings but this code was placed after the string was copied in his final buffer. So this patch correct this issue. By Aur?lien Jacobs
author albeu
date Fri, 15 Aug 2003 18:45:35 +0000
parents 57bdcdb061d7
children fd97f3727f15
line wrap: on
line diff
--- a/input/input.c	Fri Aug 15 18:02:24 2003 +0000
+++ b/input/input.c	Fri Aug 15 18:45:35 2003 +0000
@@ -601,14 +601,15 @@
 	break;
       } else if(!e) e = ptr+strlen(ptr);
       l = e-start;
-      cmd->args[i].v.s = (char*)malloc((l+1)*sizeof(char));
-      strncpy(cmd->args[i].v.s,start,l);
-      cmd->args[i].v.s[l] = '\0';
       ptr2 = start;
        for(e = strchr(ptr2,'\\') ; e ; e = strchr(ptr2,'\\')) {
 	memmove(e,e+1,strlen(e));
 	ptr2 = e + 1;
+        l--;
       }
+      cmd->args[i].v.s = (char*)malloc((l+1)*sizeof(char));
+      strncpy(cmd->args[i].v.s,start,l);
+      cmd->args[i].v.s[l] = '\0';
     } break;
     case -1:
       ptr = NULL;