From 09f7b717ac5624df9aed846fd9a0dc9eb5618396 Mon Sep 17 00:00:00 2001 From: nick black Date: Sat, 17 Dec 2022 14:10:34 -0500 Subject: [PATCH] [ncwidth] error-check printfs #2691 --- src/poc/ncwidth.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/poc/ncwidth.c b/src/poc/ncwidth.c index 22131cfd2..f46d84245 100644 --- a/src/poc/ncwidth.c +++ b/src/poc/ncwidth.c @@ -28,12 +28,18 @@ defaultout(void){ for(int i = 0 ; i < 128 ; ++i){ wint_t w = i; int width = wcwidth(w); - printf("0x%02x: %d%c\t", w, width, width < 0 ? '!' : ' '); + if(printf("0x%02x: %d%c\t", w, width, width < 0 ? '!' : ' ') < 0){ + return -1; + } if(i % 4 == 3){ - printf("\n"); + if(printf("\n") < 0){ + return -1; + } } } - printf("\n"); + if(printf("\n") < 0){ + return -1; + } return 0; }