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 <gorcunov@virtuozzo.com>
Acked-by: Andrew Vagin <avagin@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
This commit is contained in:
Cyrill Gorcunov 2016-04-14 19:04:00 +03:00 committed by Pavel Emelyanov
parent 49877012e3
commit cabfbbef36

View file

@ -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) {