From 66a9b5c3ba4f94342ed1c17cdeb0bbd9df88f72d Mon Sep 17 00:00:00 2001
From: Eli Zaretskii <eliz@gnu.org>
Date: Wed, 7 Jun 2017 08:32:35 +0300
Subject: [PATCH] Avoid crashes when SHELL=abcde is specified on the command
 line

* variable.c (do_variable_definition): If $SHELL was not found,
process "SHELL=foo" as any other variable definition.  This avoids
segfaults when SHELL=foo is specified on the Make command line.
Reported by Orgad Shaneh <orgads@gmail.com>.
---
 variable.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/variable.c b/variable.c
index ca66ecd7..364774f0 100644
--- a/variable.c
+++ b/variable.c
@@ -1404,6 +1404,11 @@ do_variable_definition (const floc *flocp, const char *varname,
         }
     }
   else
+    v = NULL;
+
+  /* If not $SHELL, or if $SHELL points to a program we didn't find,
+     just process this variable "as usual".  */
+  if (!v)
 #endif
 
   /* If we are defining variables inside an $(eval ...), we might have a