From ac576cde1d9fc0cf608be6b84f1ceb971ef55c9b Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Sat, 4 Feb 2012 11:52:10 +0100 Subject: [PATCH] * grub-core/script/execute.c (grub_script_return): Fix potential NULL-dereference. Reported by: Jim Meyering. --- ChangeLog | 6 ++++++ grub-core/script/execute.c | 6 +++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 35699d70d..38e6b9d8f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2012-02-04 Vladimir Serbinenko + + * grub-core/script/execute.c (grub_script_return): Fix potential + NULL-dereference. + Reported by: Jim Meyering. + 2012-02-03 Vladimir Serbinenko * po/POTFILES.in: Regenerate. diff --git a/grub-core/script/execute.c b/grub-core/script/execute.c index 95984fc23..97496e9ba 100644 --- a/grub-core/script/execute.c +++ b/grub-core/script/execute.c @@ -161,8 +161,12 @@ grub_script_return (grub_command_t cmd __attribute__((unused)), if (argc == 0) { + char *t; function_return = 1; - return grub_strtoul (grub_env_get ("?"), NULL, 10); + t = grub_env_get ("?"); + if (!t) + return GRUB_ERR_NONE; + return grub_strtoul (t, NULL, 10); } n = grub_strtoul (argv[0], &p, 10);