diff --git a/src/main.c b/src/main.c
index a95dd100da452cc9453bc88002d59878b952175c..7913383e105f0b21b68fd3e68f9fc1541bb63567 100644
--- a/src/main.c
+++ b/src/main.c
@@ -1579,7 +1579,9 @@ operate(struct Configurable *config, int argc, char *argv[])
       /* multiple files extracted to stdout, insert separators! */
       separator = 1;
     }
-    for (i = 0; (url = urls?next_url(urls):(i?NULL:url)); ++i) {
+    for(i = 0;
+        (url = urls?next_url(urls):(i?NULL:strdup(url)));
+        i++) {
       char *outfile;
       outfile = outfiles?strdup(outfiles):NULL;