]> git.armaanb.net Git - sic.git/commitdiff
fix an out-of-bounds read if the input is ""
authorHiltjo Posthuma <hiltjo@codemadness.org>
Wed, 5 May 2021 23:04:35 +0000 (01:04 +0200)
committerHiltjo Posthuma <hiltjo@codemadness.org>
Wed, 5 May 2021 23:04:35 +0000 (01:04 +0200)
Notified by Guilherme Janczak <guilherme.janczak@yandex.com>, thanks!

util.c

diff --git a/util.c b/util.c
index bdba7188b246412d158398b30e6a829c5442940f..25678120422eea5ec0782e9040fdd5ad24b9ff45 100644 (file)
--- a/util.c
+++ b/util.c
@@ -61,7 +61,7 @@ trim(char *s) {
        char *e;
 
        e = s + strlen(s) - 1;
-       while(isspace(*e) && e > s)
+       while(e > s && isspace(*e))
                e--;
        *(e + 1) = '\0';
 }