fairyglade / ly

display manager with console UI
Do What The F*ck You Want To Public License
5.47k stars 305 forks source link

Fix matrix animation crash when terminal height is 3 #565

Closed wr7 closed 8 months ago

wr7 commented 10 months ago

Current behavior

If the matrix animation is enabled and the terminal height is 3, the modulus operation on draw.c::724 will raise an Arithmetic Exception. This will cause ly to crash.

724 |  s->length[j] = (int) rand() % (buf->height - 3) + 3;
                                   ^^^^^^^^^^^^^^^^^^^

The same thing could happen on line 861:

861 | s->length[j] = (int) rand() % (buf->height - 3) + 3;
                                  ^^^^^^^^^^^^^^^^^^^

New behavior

Ly will not attempt to display the matrix animation if buf->height <= 3.