From 13fb787f0ec0fb9aa25960a73629b748a8868340 Mon Sep 17 00:00:00 2001 From: Cody Boone Ferguson <53008573+xexyl@users.noreply.github.com> Date: Sun, 26 Mar 2023 13:07:22 -0700 Subject: [PATCH] Fix segfault without arg in 2001/cheong --- 2001/cheong/README.md | 5 +++-- 2001/cheong/cheong.c | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/2001/cheong/README.md b/2001/cheong/README.md index 0e1febd83..29f75f937 100644 --- a/2001/cheong/README.md +++ b/2001/cheong/README.md @@ -15,8 +15,9 @@ make [Cody Boone Ferguson](/winners.html#Cody_Boone_Ferguson) fixed this to work with clang by adding another function that is allowed to have a third arg as an int, not a `char **`. He chose pain() because it's a four letter word that would -match the format and because it's pain that clang forces this. :-) Thank you -Cody for your assistance! +match the format and because it's pain that clang forces this. :-) He also fixed +a segfault in the case that no arg is specified. Thank you Cody for your +assistance! ### To run: diff --git a/2001/cheong/cheong.c b/2001/cheong/cheong.c index 97fef5f18..dbd583fe6 100644 --- a/2001/cheong/cheong.c +++ b/2001/cheong/cheong.c @@ -11,4 +11,4 @@ c=o+ (D[I]+82)%10-(I>l/2)* :!(o=pain(c/10,O,I-1))*((c+999 )%10-(D[I]+92)%10);}return o;} int main(int o,char **O) { -return pain(o, O, l); } +return O[1]?pain(o, O, l):1; }