src__lib__libast__sfio__sfvprintf.c.diff   [plain text]


--- src/lib/libast/sfio/sfvprintf.c.orig	2016-09-14 15:24:35.000000000 -0700
+++ src/lib/libast/sfio/sfvprintf.c	2016-09-13 17:35:16.000000000 -0700
@@ -714,9 +714,11 @@ loop_fmt :
 #ifdef mbwidth
 						if(wc)
 						{	n_w = mbwidth(*wsp);
+							if (n_w > 0) {
 							if(precis >= 0 && (w+n_w) > precis )
 								break;
 							w += n_w;
+							}
 						}
 						else
 #endif
@@ -740,10 +742,14 @@ loop_fmt :
 							break;
 						osp = ssp;
 						n = mbchar(osp);
+						if (!n) 
+							break;
 						n_w = mbwidth(n);
+						if (n_w > 0) {
 						if(precis >= 0 && (w+n_w) > precis )
 							break;
 						w += n_w;
+						}
 						ssp = osp;
 					}
 					v = ssp - sp;