]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
criu: DECLARE_ARG should check for null arguments
authorTycho Andersen <tycho.andersen@canonical.com>
Wed, 8 Oct 2014 17:12:04 +0000 (17:12 +0000)
committerSerge Hallyn <serge.hallyn@ubuntu.com>
Wed, 8 Oct 2014 17:47:13 +0000 (12:47 -0500)
This is in preparation for the cgroups creation work, but also probably just a
good idea in general. The ERROR message is handy since we print line nos. it
will to give people an indication of what arg was null.

Signed-off-by: Tycho Andersen <tycho.andersen@canonical.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
src/lxc/lxccontainer.c

index 4f90f356effd74842b34b59f94604ada62affc81..fee758d2ddd6f0d709ac4eb61a8582e81cf4e5f5 100644 (file)
@@ -3554,11 +3554,15 @@ static void exec_criu(struct criu_opts *opts)
 
        memset(argv, 0, static_args * sizeof(*argv));
 
-#define DECLARE_ARG(arg)                       \
-       do {                                    \
-               argv[argc++] = strdup(arg);     \
-               if (!argv[argc-1])              \
-                       goto err;               \
+#define DECLARE_ARG(arg)                                       \
+       do {                                                    \
+               if (arg == NULL) {                              \
+                       ERROR("Got NULL argument for criu");    \
+                       goto err;                               \
+               }                                               \
+               argv[argc++] = strdup(arg);                     \
+               if (!argv[argc-1])                              \
+                       goto err;                               \
        } while (0)
 
        argv[argc++] = on_path("criu", NULL);