t6050-replace: make failing editor test more robust
[gitweb.git] / http-backend.c
index 57290d9bdafc730afaac3ddf8564d85ead39eb31..80790bbaef95a56ac737c7763e48035e3e0754ee 100644 (file)
@@ -610,9 +610,7 @@ int main(int argc, char **argv)
 
                        cmd = c;
                        n = out[0].rm_eo - out[0].rm_so;
-                       cmd_arg = xmalloc(n);
-                       memcpy(cmd_arg, dir + out[0].rm_so + 1, n-1);
-                       cmd_arg[n-1] = '\0';
+                       cmd_arg = xmemdupz(dir + out[0].rm_so + 1, n - 1);
                        dir[out[0].rm_so] = 0;
                        break;
                }