diff --git a/src/tool_operate.c b/src/tool_operate.c
index 4969c41931..84da414ada 100644
--- a/src/tool_operate.c
+++ b/src/tool_operate.c
@@ -1076,8 +1076,9 @@ static CURLcode setup_outfile(struct OperationConfig *config,
}
}
else {
- per->outfile = u->outfile;
- u->outfile = NULL;
+ per->outfile = curlx_strdup(u->outfile);
+ if(!per->outfile)
+ return CURLE_OUT_OF_MEMORY;
}
DEBUGASSERT(per->outfile);
diff --git a/tests/data/Makefile.am b/tests/data/Makefile.am
index 2c25c0b1d2..dc0d8311ec 100644
--- a/tests/data/Makefile.am
+++ b/tests/data/Makefile.am
@@ -245,7 +245,7 @@ test1970 test1971 test1972 test1973 test1974 test1975 test1976 test1977 \
test1978 test1979 test1980 test1981 test1982 test1983 test1984 \
\
test2000 test2001 test2002 test2003 test2004 test2005 test2006 test2007 \
-test2008 test2009 test2010 test2011 \
+test2008 test2009 test2010 test2011 test2012 test2013 \
\
test2023 \
test2024 test2025 test2026 test2027 test2028 test2029 test2030 test2031 \
diff --git a/tests/data/test2012 b/tests/data/test2012
new file mode 100644
index 0000000000..ecc64891af
--- /dev/null
+++ b/tests/data/test2012
@@ -0,0 +1,95 @@
+
+
+
+
+HTTP
+HTTP PUT
+
+
+
+# Server-side
+
+
+HTTP/1.1 200 OK
+Date: Tue, 09 Nov 2010 14:49:00 GMT
+Server: test-server/fake
+Accept-Ranges: bytes
+Content-Length: 6
+Connection: close
+Content-Type: text/html
+
+-foo-
+
+
+HTTP/1.1 200 the second one
+Date: Tue, 09 Nov 2010 14:49:00 GMT
+Server: test-server/fake
+Accept-Ranges: bytes
+Content-Length: 6
+Connection: close
+Content-Type: text/html
+
+again
+
+
+
+# Client-side
+
+
+http
+
+
+load URLs from a file, upload with a glob
+
+
+-T '%LOGDIR/upload{1,2}' --url @%LOGDIR/urls --silent --output=%LOGDIR/first-out --output=%LOGDIR/second-out
+
+
+
+first!
+
+
+
+second
+
+
+
+http://%HOSTIP:%HTTPPORT/%TESTNUMBER
+http://%HOSTIP:%HTTPPORT/%TESTNUMBER0002
+
+
+
+
+# Verify data after the test has been "shot"
+
+
+PUT /%TESTNUMBER HTTP/1.1
+Host: %HOSTIP:%HTTPPORT
+User-Agent: curl/%VERSION
+Accept: */*
+Content-Length: 7
+
+first!
+PUT /%TESTNUMBER HTTP/1.1
+Host: %HOSTIP:%HTTPPORT
+User-Agent: curl/%VERSION
+Accept: */*
+Content-Length: 7
+
+second
+GET /%TESTNUMBER0002 HTTP/1.1
+Host: %HOSTIP:%HTTPPORT
+User-Agent: curl/%VERSION
+Accept: */*
+
+GET /%TESTNUMBER0002 HTTP/1.1
+Host: %HOSTIP:%HTTPPORT
+User-Agent: curl/%VERSION
+Accept: */*
+
+
+
+%EMPTY
+
+
+
diff --git a/tests/data/test2013 b/tests/data/test2013
new file mode 100644
index 0000000000..b5dfa10ee6
--- /dev/null
+++ b/tests/data/test2013
@@ -0,0 +1,90 @@
+
+
+
+
+HTTP
+HTTP PUT
+
+
+
+# Server-side
+
+
+HTTP/1.1 200 OK
+Date: Tue, 09 Nov 2010 14:49:00 GMT
+Server: test-server/fake
+Accept-Ranges: bytes
+Content-Length: 6
+Connection: close
+Content-Type: text/html
+
+-foo-
+
+
+HTTP/1.1 200 the second one
+Date: Tue, 09 Nov 2010 14:49:00 GMT
+Server: test-server/fake
+Accept-Ranges: bytes
+Content-Length: 6
+Connection: close
+Content-Type: text/html
+
+again
+
+
+
+# Client-side
+
+
+http
+
+
+upload with a glob
+
+
+-T '%LOGDIR/upload{1,2}' http://%HOSTIP:%HTTPPORT/%TESTNUMBER http://%HOSTIP:%HTTPPORT/%TESTNUMBER0002 --silent --output=%LOGDIR/first-out --output=%LOGDIR/second-out
+
+
+
+first!
+
+
+
+second
+
+
+
+
+# Verify data after the test has been "shot"
+
+
+PUT /%TESTNUMBER HTTP/1.1
+Host: %HOSTIP:%HTTPPORT
+User-Agent: curl/%VERSION
+Accept: */*
+Content-Length: 7
+
+first!
+PUT /%TESTNUMBER HTTP/1.1
+Host: %HOSTIP:%HTTPPORT
+User-Agent: curl/%VERSION
+Accept: */*
+Content-Length: 7
+
+second
+GET /%TESTNUMBER0002 HTTP/1.1
+Host: %HOSTIP:%HTTPPORT
+User-Agent: curl/%VERSION
+Accept: */*
+
+GET /%TESTNUMBER0002 HTTP/1.1
+Host: %HOSTIP:%HTTPPORT
+User-Agent: curl/%VERSION
+Accept: */*
+
+
+
+%EMPTY
+
+
+