]> Savannah Git Hosting - gnulib.git/commitdiff
vasnprintf-posix: Fix negative width handling for %ls directive.
authorBruno Haible <bruno@clisp.org>
Sat, 28 Jan 2023 17:17:17 +0000 (18:17 +0100)
committerBruno Haible <bruno@clisp.org>
Fri, 10 Feb 2023 02:21:52 +0000 (03:21 +0100)
Reported by clang via Po Lu <luangruo@yahoo.com>.

* lib/vasnprintf.c (VASNPRINTF): In the code for %ls in vasnprintf and
for %s in vasnwprintf, test for the FLAG_LEFT bit in the flags variable.

ChangeLog
lib/vasnprintf.c

index a892621b40f2f4c8a9d391d2918215a963336be3..207dd0f003dab40a5f813dbd6c5bd04dd2e53002 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2023-01-28  Bruno Haible  <bruno@clisp.org>
+
+       vasnprintf-posix: Fix negative width handling for %ls directive.
+       Reported by clang via Po Lu <luangruo@yahoo.com>.
+       * lib/vasnprintf.c (VASNPRINTF): In the code for %ls in vasnprintf and
+       for %s in vasnwprintf, test for the FLAG_LEFT bit in the flags variable.
+
 2023-01-28  Bruno Haible  <bruno@clisp.org>
 
        Avoid clang warnings regarding [[__nodiscard__]].
index 277c39e3e07a9ecc1c35e0158b278521e4c5241c..5ab8edbab7a7dfc780ab9a57d7db662d5f845d0b 100644 (file)
@@ -2551,7 +2551,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
                       characters = 0;
                     }
 
-                  if (characters < width && !(dp->flags & FLAG_LEFT))
+                  if (characters < width && !(flags & FLAG_LEFT))
                     {
                       size_t n = width - characters;
                       ENSURE_ALLOCATION (xsum (length, n));
@@ -2612,7 +2612,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
                         }
                     }
 
-                  if (characters < width && (dp->flags & FLAG_LEFT))
+                  if (characters < width && (flags & FLAG_LEFT))
                     {
                       size_t n = width - characters;
                       ENSURE_ALLOCATION (xsum (length, n));
@@ -2768,7 +2768,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));
@@ -2836,7 +2836,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));