From cabfbbef36569032e4d873d208d447e2789733db Mon Sep 17 00:00:00 2001 From: Cyrill Gorcunov Date: Thu, 14 Apr 2016 19:04:00 +0300 Subject: [PATCH] criu: action-scripts -- Don't access @root_item_pid if not present It might be nil on predump, so dereference only when present. Signed-off-by: Cyrill Gorcunov Acked-by: Andrew Vagin Signed-off-by: Pavel Emelyanov --- criu/action-scripts.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/criu/action-scripts.c b/criu/action-scripts.c index db3bfc3dd..addc83387 100644 --- a/criu/action-scripts.c +++ b/criu/action-scripts.c @@ -48,10 +48,12 @@ int run_scripts(enum script_actions act) return -1; } - snprintf(root_item_pid, sizeof(root_item_pid), "%d", root_item->pid.real); - if (setenv("CRTOOLS_INIT_PID", root_item_pid, 1)) { - pr_perror("Can't set CRTOOLS_INIT_PID=%s", root_item_pid); - return -1; + if (root_item) { + snprintf(root_item_pid, sizeof(root_item_pid), "%d", root_item->pid.real); + if (setenv("CRTOOLS_INIT_PID", root_item_pid, 1)) { + pr_perror("Can't set CRTOOLS_INIT_PID=%s", root_item_pid); + return -1; + } } list_for_each_entry(script, &opts.scripts, node) {