Fix weird printing to console that sometimes happened with listImages

It sometimes happened when changing image_* cvars for compression and
then vid_restarting and then running listImages.
In one case the whole process hung and len was a ridiculously big number
=> most probably the (unsigned!) size_t overflowed by subtracting a
number > len (most likely from input_field.GetCursor()).

So I just made it a plain signed int.
I couldn't reproduce the issue anymore after doing this change.
This commit is contained in:
Daniel Gibson 2025-04-08 05:47:39 +02:00
parent b050991ed2
commit f3cd3f31d0

View file

@ -828,7 +828,9 @@ void tty_Show() {
input_hide--;
if ( input_hide == 0 ) {
char *buf = input_field.GetBuffer();
size_t len = strlen(buf);
// DG: it happened (not sure how) that len became very big,
// most likely because of an overflow (underflow?) so I made it signed
int len = strlen(buf);
if ( len < 1 )
return;