summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonathan Lebon <jlebon@redhat.com>2016-07-22 09:21:09 -0400
committerColin Walters <walters@verbum.org>2016-07-22 09:36:51 -0400
commitc072ef1ebab052bdecb0d9a52c14813728f83859 (patch)
tree8a91115fa46fee299992ad83e22fb862925edee6
parentd2e588d94fabacfeb5b08790365161a015a00b98 (diff)
downloadlibglnx-c072ef1ebab052bdecb0d9a52c14813728f83859.tar.gz
text_percent_internal: compare uints before printing
A wild sordid tale of substractions and unsigned integers leads this team of variables down a loonng path... Reported-by: Gatis Paeglis <gatis.paeglis@qt.io>
-rw-r--r--glnx-console.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/glnx-console.c b/glnx-console.c
index d40702e..416d276 100644
--- a/glnx-console.c
+++ b/glnx-console.c
@@ -221,9 +221,11 @@ text_percent_internal (const char *text,
if (percentage == -1)
{
- const guint spacelen = ncolumns - input_textlen;
fwrite (text, 1, input_textlen, stdout);
- printpad (spaces, n_spaces, spacelen);
+
+ /* Overwrite remaining space, if any */
+ if (ncolumns > input_textlen)
+ printpad (spaces, n_spaces, ncolumns - input_textlen);
}
else
{