From 37d3a8e77f72ca0daacf8d082a0872d4f216e3e5 Mon Sep 17 00:00:00 2001 From: Quinn Date: Wed, 23 Apr 2025 16:53:49 +0200 Subject: [PATCH] improve error handling --- src/game/opts.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/game/opts.c b/src/game/opts.c index c653de4..720fd4c 100644 --- a/src/game/opts.c +++ b/src/game/opts.c @@ -55,7 +55,7 @@ __attribute__((nonnull(1, 3))) static inline int str_put(char* restrict* restric } // copy the missing data to the end of the destination - memcpy(*dest + dest_len, src + dest_len, src_len - dest_len); + memcpy(*dest + dest_len, src, src_len - dest_len); (*dest)[src_len] = '\0'; // null-terminate the destination return 0; } @@ -143,6 +143,8 @@ int load_opts(void) { while (fgets(buf, BUF_SIZE, fptr)) { // process the data in the current buffer proc_buf(buf, &dat); + if (dat.pkey) debug("key: '%s'", dat.pkey); + if (dat.pval) debug("val: '%s'", dat.pval); // ignore if EOL hasn't been reached yet, due to the built up data possibly being incomplete if (!dat.eol) continue;