| Date: Sat, 14 Mar 2009 14:00:35 +0800 | From: "Clark J. Wang" | To: Bash - Bug | Subject: [bash-bug] [PATCH] bash-4.0.10: segfault with `; &' at the end of case statement | | With bash version: 4.0.10, the following case statement crashed with | segfault: | | $ cat foo.sh | case a in | a) echo a ;& | esac | $ bash4 foo.sh | a | Segmentation fault | $ | | In an interactive shell, that case statement causes current shell to hang | with nearly 100% CPU usage. | | The following patch fixes this for me: | *** execute_cmd.c 2009-02-14 05:41:41.000000000 +0800 --- execute_cmd.c 2009-03-14 13:47:15.000000000 +0800 *************** *** 2932,2938 **** retval = execute_command (clauses->action); } while ((clauses->flags & CASEPAT_FALLTHROUGH) && (clauses = clauses->next)); ! if ((clauses->flags & CASEPAT_TESTNEXT) == 0) EXIT_CASE (); else break; --- 2932,2938 ---- retval = execute_command (clauses->action); } while ((clauses->flags & CASEPAT_FALLTHROUGH) && (clauses = clauses->next)); ! if (!clauses || (clauses->flags & CASEPAT_TESTNEXT) == 0) EXIT_CASE (); else break;