From f44003e07cba0bf2f5bd3aa6fd0ffe16f9432376 Mon Sep 17 00:00:00 2001 From: Phil Date: Tue, 4 Nov 2008 21:42:48 +0000 Subject: [PATCH] fix a potential segfault * happened when passing wrong arguments to ${scroll}, particularly with only one instead of the mandatory two unsigned ints * as it's not clear whether %n will change the value returned by sscanf or not, use a solution that works in both situations (%n incrementing the return value or not) git-svn-id: https://conky.svn.sourceforge.net/svnroot/conky/trunk/conky1@1268 7f574dfc-610e-0410-a909-a81674777703 --- src/conky.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/conky.c b/src/conky.c index 878f8a41..6ddd6039 100644 --- a/src/conky.c +++ b/src/conky.c @@ -4218,7 +4218,7 @@ static struct text_object *construct_text_object(const char *s, int n; obj->data.scroll.step = 1; - if (arg && sscanf(arg, "%u %u %n", &obj->data.scroll.show, &obj->data.scroll.step, &n) > 0) { + if (arg && sscanf(arg, "%u %u %n", &obj->data.scroll.show, &obj->data.scroll.step, &n) >= 2) { obj->data.scroll.text = strndup(arg + n, text_buffer_size); obj->data.scroll.start = 0; } else {