From 46037061b05003c17558cf44ee80b7e3e8df2ff6 Mon Sep 17 00:00:00 2001 From: William McBrine Date: Sat, 21 Apr 2007 01:52:53 +0000 Subject: [PATCH] Bounds-checking for the trailing-spaces strip (oops). I'm going back and forth on the whole thing... it's clear to me that the real intent of the standard is just that the labels not be returned in their padded or justified form; spaces passed in by the user need not be covered, and perhaps should not be. --- pdcurses/slk.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pdcurses/slk.c b/pdcurses/slk.c index 6670bfc1..37990adb 100644 --- a/pdcurses/slk.c +++ b/pdcurses/slk.c @@ -14,7 +14,7 @@ #include #include -RCSID("$Id: slk.c,v 1.50 2007/04/19 18:03:16 wmcbrine Exp $"); +RCSID("$Id: slk.c,v 1.51 2007/04/21 01:52:53 wmcbrine Exp $"); /*man-start************************************************************** @@ -255,7 +255,7 @@ int slk_set(int labnum, const char *label, int justify) /* Drop trailing spaces */ - while (label[i + j - 1] == ' ') + while ((i + j) && (label[i + j - 1] == ' ')) i--; slk[labnum].label[i] = 0; @@ -618,7 +618,7 @@ int slk_wset(int labnum, const wchar_t *label, int justify) /* Drop trailing spaces */ - while (label[i + j - 1] == L' ') + while ((i + j) && (label[i + j - 1] == L' ')) i--; slk[labnum].label[i] = 0;