@@ -316,26 +316,28 @@ static void LEDMeterMode_draw(Meter* this, int x, int y, int w) {
316
316
attrset (CRT_colors [LED_COLOR ]);
317
317
const char * caption = Meter_getCaption (this );
318
318
mvaddstr (yText , x , caption );
319
- int xx = x + (int )strlen (caption );
320
- size_t len = RichString_sizeVal (out );
321
- for (size_t i = 0 ; i < len ; i ++ ) {
322
- int c = RichString_getCharVal (out , i );
323
- if (c >= '0' && c <= '9' ) {
324
- if (xx - x + 4 > w )
325
- break ;
326
-
327
- LEDMeterMode_drawDigit (xx , y , c - '0' );
328
- xx += 4 ;
329
- } else {
330
- if (xx - x + 1 > w )
331
- break ;
319
+ if (strlen (caption ) <= INT_MAX - (unsigned int )x ) {
320
+ int xx = x + (int )strlen (caption );
321
+ size_t len = RichString_sizeVal (out );
322
+ for (size_t i = 0 ; i < len ; i ++ ) {
323
+ int c = RichString_getCharVal (out , i );
324
+ if (c >= '0' && c <= '9' ) {
325
+ if (xx - x + 4 > w )
326
+ break ;
327
+
328
+ LEDMeterMode_drawDigit (xx , y , c - '0' );
329
+ xx += 4 ;
330
+ } else {
331
+ if (xx - x + 1 > w )
332
+ break ;
332
333
#ifdef HAVE_LIBNCURSESW
333
- const cchar_t wc = { .chars = { c , '\0' }, .attr = 0 }; /* use LED_COLOR from attrset() */
334
- mvadd_wch (yText , xx , & wc );
334
+ const cchar_t wc = { .chars = { c , '\0' }, .attr = 0 }; /* use LED_COLOR from attrset() */
335
+ mvadd_wch (yText , xx , & wc );
335
336
#else
336
- mvaddch (yText , xx , c );
337
+ mvaddch (yText , xx , c );
337
338
#endif
338
- xx += 1 ;
339
+ xx += 1 ;
340
+ }
339
341
}
340
342
}
341
343
attrset (CRT_colors [RESET_COLOR ]);
0 commit comments