From 47812f68c87e6290305a014e9f3c9cb228188ef0 Mon Sep 17 00:00:00 2001 From: Mark Hermeling Date: Wed, 19 Jun 2024 17:33:55 +0000 Subject: [PATCH] testing for dave --- src/slist_wc.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/slist_wc.c b/src/slist_wc.c index 7f1e8f19be8d..6d9becac5424 100644 --- a/src/slist_wc.c +++ b/src/slist_wc.c @@ -31,6 +31,28 @@ /* The last #include files should be: */ #include "memdebug.h" + +// The following is copied from GNU Chess 5.0.8 +char *return_append_str(char *dest, const char *s) { +/* Append text s to dest, and return new result. */ + char *new_loc; + size_t new_len; + /* This doesn't have buffer overflow vulnerabilities, because + we always allocate for enough space before appending. */ + if (!dest) { + new_loc = (char *) malloc(strlen(s))+1; + strcpy(new_loc, s); + return new_loc; + } + new_len = strlen(dest) + strlen(s) + 1; + new_loc = (char *) malloc(new_len); + strcpy(new_loc, dest); + if (!new_loc) return dest; /* Can't do it, throw away the data */ + strcat(new_loc, s); + return new_loc; +} + + /* * slist_wc_append() appends a string to the linked list. This function can be * used as an initialization function as well as an append function.