From 0c07302777005c0e1e62708af210412786242c48 Mon Sep 17 00:00:00 2001 From: Cody Boone Ferguson <53008573+xexyl@users.noreply.github.com> Date: Fri, 24 Mar 2023 10:40:12 -0700 Subject: [PATCH] Fix segfault in 2006/birken under macOS The problem was a missing +1 for strlen() in a malloc() call. This entry still uses gets() and strangely changing it to fgets() makes it segfault but I'll worry about this later when more entries have been checked and (if possible) fixed. --- 2006/birken/README.md | 4 ++++ 2006/birken/birken.c | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/2006/birken/README.md b/2006/birken/README.md index b246c5fc9..a1a2d85ef 100644 --- a/2006/birken/README.md +++ b/2006/birken/README.md @@ -18,6 +18,10 @@ make ./birken < file.tofu ``` +[Cody Boone Ferguson](/winners.html#Cody_Boone_Ferguson) fixed a segfault in +macOS with this entry. The problem was a missing `+1` for strlen() with +malloc(). Thank you Cody for your assistance! + ### Try: ```sh diff --git a/2006/birken/birken.c b/2006/birken/birken.c index eb5398792..638705d15 100644 --- a/2006/birken/birken.c +++ b/2006/birken/birken.c @@ -64,7 +64,7 @@ _=z->o; c=_->o->_; a= c->_->_->o; c=_ ->c++; h(c); } Q Z(a->cc){ a ->c++; h(a); } z=z->_; } } X* v(X*_,int O){ X*s=(X*)m\ -alloc(strlen(_)*siz\ +alloc(1+strlen(_)*siz\ eof(X)); X*l=s; J((*l++=*_? *_-O:0)