]> 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:58:16 +0000 (03:58 +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 b9ca4abe35fd39f62513cfb044e3c2b7eb58f68b..bf7aed08122fa8aaa2d3eff0e7a4cabb3ac6c9ee 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 6eb33c87407cd90d3b27c2508590ab7c114fc6ac..6fc1acbe5b85ed766a2676e7b06b17ef47011fdb 100644 (file)
@@ -1,5 +1,5 @@
 /* vsprintf with automatic memory allocation.
-   Copyright (C) 1999, 2002-2022 Free Software Foundation, Inc.
+   Copyright (C) 1999, 2002-2023 Free Software Foundation, Inc.
 
    This file is free software: you can redistribute it and/or modify
    it under the terms of the GNU Lesser General Public License as
@@ -2552,7 +2552,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));
@@ -2613,7 +2613,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));
@@ -2769,7 +2769,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));
@@ -2837,7 +2837,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));