diff --git a/src/lib/core/popen.c b/src/lib/core/popen.c
index 10599f1496db7a60ad9f4dad2e7d996c60c504ed..fcef6f6d90fec183e3078f0bb2b735b653c66dff 100644
--- a/src/lib/core/popen.c
+++ b/src/lib/core/popen.c
@@ -1215,7 +1215,9 @@ popen_new(struct popen_opts *opts)
 	int *skip_fds = xregion_alloc_array(region, typeof(skip_fds[0]),
 					    nr_skip_fds_max);
 	size_t nr_skip_fds = opts->nr_inherit_fds;
-	memcpy(skip_fds, opts->inherit_fds, nr_skip_fds * sizeof(*skip_fds));
+	if (nr_skip_fds > 0)
+		memcpy(skip_fds, opts->inherit_fds,
+		       nr_skip_fds * sizeof(*skip_fds));
 
 	if (log_fd >= 0)
 		skip_fds[nr_skip_fds++] = log_fd;