From 04b2b5979702e989334a3eb0eb1b13fe74f25e72 Mon Sep 17 00:00:00 2001 From: Cody Boone Ferguson <53008573+xexyl@users.noreply.github.com> Date: Sun, 26 Mar 2023 15:07:35 -0700 Subject: [PATCH] Fix segfault in 1992/westley without enough args --- 1992/westley/README.md | 4 +++- 1992/westley/westley.c | 4 ++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/1992/westley/README.md b/1992/westley/README.md index a28c09d7d..53a235dda 100644 --- a/1992/westley/README.md +++ b/1992/westley/README.md @@ -15,7 +15,9 @@ [Cody Boone Ferguson](/winners.html#Cody_Boone_Ferguson) fixed this for clang by changing the third and fourth arg of main() to be ints inside main(); clang -requires args 2 - 4 to be `char **`. Thank you Cody for your assistance! +requires args 2 - 4 to be `char **`. He also fixed it so that the program would +not segfault if not enough args were specified. Thank you Cody for your +assistance! ### To run diff --git a/1992/westley/westley.c b/1992/westley/westley.c index 2fe9a369c..155219033 100644 --- a/1992/westley/westley.c +++ b/1992/westley/westley.c @@ -1,7 +1,7 @@ main(l ,a)char**a;{int n;int d; - for(d=atoi(a[1])/10*80- - atoi(a[2])/5-596;n="@NKA\ + if (l>2)for(d=atoi(a[1])/10 + *80-atoi(a[2])/5-596;n="@NKA\ CLCCGZAAQBEAADAFaISADJABBA^\ SNLGAQABDAXIMBAACTBATAHDBAN\ ZcEMMCCCCAAhEIJFAEAAABAfHJE\