]> Savannah Git Hosting - gnulib.git/commitdiff
vasnprintf-posix: Fix possible bug with negative width handling for %lc.
authorBruno Haible <bruno@clisp.org>
Sat, 28 Jan 2023 18:05:24 +0000 (19:05 +0100)
committerBruno Haible <bruno@clisp.org>
Fri, 10 Feb 2023 02:23:04 +0000 (03:23 +0100)
* lib/vasnprintf.c (VASNPRINTF): In the code for %lc in vasnprintf, test
for the FLAG_LEFT bit in the flags variable.

ChangeLog
lib/vasnprintf.c

index 207dd0f003dab40a5f813dbd6c5bd04dd2e53002..622e4f7ffd6350335060a4bd55c2a5d22fc8da36 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2023-01-28  Bruno Haible  <bruno@clisp.org>
+
+       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  <bruno@clisp.org>
 
        vasnprintf-posix: Fix negative width handling for %ls directive.
index 5ab8edbab7a7dfc780ab9a57d7db662d5f845d0b..0e6220ae18c4d7021f3fe579248551eb2c593cd6 100644 (file)
@@ -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));