git: 0bf5d86620d0 - main - stdio: Fix error case for positional %wN / %wfN

From: Dag-Erling Smørgrav <des_at_FreeBSD.org>
Date: Mon, 16 Nov 2026 12:29:00 UTC
The branch main has been updated by des:

URL: https://cgit.FreeBSD.org/src/commit/?id=0bf5d86620d047b4551d7414bf8011a328264b3d

commit 0bf5d86620d047b4551d7414bf8011a328264b3d
Author:     Dag-Erling Smørgrav <des@FreeBSD.org>
AuthorDate: 2026-11-16 11:45:15 +0000
Commit:     Dag-Erling Smørgrav <des@FreeBSD.org>
CommitDate: 2026-11-16 12:05:54 +0000

    stdio: Fix error case for positional %wN / %wfN
    
    In the case were N was not a valid bit width, we were taking the wrong
    error path.
    
    Fixes:          5e809bf1c93f ("stdio: Fix positional %wN / %wfN conversion")
---
 lib/libc/stdio/printf-pos.c          | 4 ++--
 lib/libc/tests/stdio/snprintf_test.c | 2 ++
 lib/libc/tests/stdio/swprintf_test.c | 2 ++
 3 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/lib/libc/stdio/printf-pos.c b/lib/libc/stdio/printf-pos.c
index fd92b3d5ad29..c395144dbd7d 100644
--- a/lib/libc/stdio/printf-pos.c
+++ b/lib/libc/stdio/printf-pos.c
@@ -368,7 +368,7 @@ reswitch:	switch (ch) {
 					flags &= ~FASTINT;
 					fmt--;
 				}
-				goto error;
+				break;
 			}
 			goto rflag;
 		case 'z':
@@ -597,7 +597,7 @@ reswitch:	switch (ch) {
 					flags &= ~FASTINT;
 					fmt--;
 				}
-				goto error;
+				break;
 			}
 			goto rflag;
 		case 'z':
diff --git a/lib/libc/tests/stdio/snprintf_test.c b/lib/libc/tests/stdio/snprintf_test.c
index b805f513c402..392fb43f9795 100644
--- a/lib/libc/tests/stdio/snprintf_test.c
+++ b/lib/libc/tests/stdio/snprintf_test.c
@@ -175,6 +175,7 @@ ATF_TC_BODY(snprintf_wN, tc)
 	SNPRINTF_TEST(" 1", "%1$*2$w16d", (int16_t)1, 2);
 	SNPRINTF_TEST(" 1", "%1$*2$w32d", (int32_t)1, 2);
 	SNPRINTF_TEST(" 1", "%1$*2$w64d", (int64_t)1, 2);
+	SNPRINTF_TEST("42w42d", "%1$d%w42d", 42);
 }
 
 ATF_TC_WITHOUT_HEAD(snprintf_wfN);
@@ -211,6 +212,7 @@ ATF_TC_BODY(snprintf_wfN, tc)
 	SNPRINTF_TEST(" 1", "%1$*2$w16d", (int_fast16_t)1, 2);
 	SNPRINTF_TEST(" 1", "%1$*2$w32d", (int_fast32_t)1, 2);
 	SNPRINTF_TEST(" 1", "%1$*2$w64d", (int_fast64_t)1, 2);
+	SNPRINTF_TEST("42wf42d", "%1$d%wf42d", 42);
 }
 
 ATF_TP_ADD_TCS(tp)
diff --git a/lib/libc/tests/stdio/swprintf_test.c b/lib/libc/tests/stdio/swprintf_test.c
index 6f3d56657f4c..6a9e68c9d5fd 100644
--- a/lib/libc/tests/stdio/swprintf_test.c
+++ b/lib/libc/tests/stdio/swprintf_test.c
@@ -176,6 +176,7 @@ ATF_TC_BODY(swprintf_wN, tc)
 	SWPRINTF_TEST(" 1", "%1$*2$w16d", (int16_t)1, 2);
 	SWPRINTF_TEST(" 1", "%1$*2$w32d", (int32_t)1, 2);
 	SWPRINTF_TEST(" 1", "%1$*2$w64d", (int64_t)1, 2);
+	SWPRINTF_TEST("42w42d", "%1$d%w42d", 42);
 }
 
 ATF_TC_WITHOUT_HEAD(swprintf_wfN);
@@ -212,6 +213,7 @@ ATF_TC_BODY(swprintf_wfN, tc)
 	SWPRINTF_TEST(" 1", "%1$*2$w16d", (int_fast16_t)1, 2);
 	SWPRINTF_TEST(" 1", "%1$*2$w32d", (int_fast32_t)1, 2);
 	SWPRINTF_TEST(" 1", "%1$*2$w64d", (int_fast64_t)1, 2);
+	SWPRINTF_TEST("42wf42d", "%1$d%wf42d", 42);
 }
 
 ATF_TP_ADD_TCS(tp)