From e29429542765714059560828c58c726bf0d6341e Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Sat, 28 Jan 2023 19:05:24 +0100 Subject: [PATCH] vasnprintf-posix: Fix possible bug with negative width handling for %lc. * lib/vasnprintf.c (VASNPRINTF): In the code for %lc in vasnprintf, test for the FLAG_LEFT bit in the flags variable. --- ChangeLog | 6 ++++++ lib/vasnprintf.c | 4 ++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 207dd0f003..622e4f7ffd 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2023-01-28 Bruno Haible + + vasnprintf-posix: Fix possible bug with negative width handling for %lc. + * lib/vasnprintf.c (VASNPRINTF): In the code for %lc in vasnprintf, test + for the FLAG_LEFT bit in the flags variable. + 2023-01-28 Bruno Haible vasnprintf-posix: Fix negative width handling for %ls directive. diff --git a/lib/vasnprintf.c b/lib/vasnprintf.c index 5ab8edbab7..0e6220ae18 100644 --- a/lib/vasnprintf.c +++ b/lib/vasnprintf.c @@ -2977,7 +2977,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp, /* w doesn't matter. */ w = 0; - if (w < width && !(dp->flags & FLAG_LEFT)) + if (w < width && !(flags & FLAG_LEFT)) { size_t n = width - w; ENSURE_ALLOCATION (xsum (length, n)); @@ -3033,7 +3033,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp, length += tmpdst_len; # endif - if (w < width && (dp->flags & FLAG_LEFT)) + if (w < width && (flags & FLAG_LEFT)) { size_t n = width - w; ENSURE_ALLOCATION (xsum (length, n)); -- 2.39.5