LOLWUT: fix crash when col < 2.

Close #5345.
This commit is contained in:
antirez 2018-09-13 08:08:28 +02:00
parent 690560e8db
commit 4dc37c240e

View File

@ -177,7 +177,7 @@ void lwDrawSquare(lwCanvas *canvas, int x, int y, float size, float angle) {
lwCanvas *lwDrawSchotter(int console_cols, int squares_per_row, int squares_per_col) {
/* Calculate the canvas size. */
int canvas_width = console_cols*2;
int padding = 2;
int padding = console_cols > 2 ? 2 : 0;
float square_side = (float)(canvas_width-padding*2) / squares_per_row;
int canvas_height = square_side * squares_per_col + padding*2;
lwCanvas *canvas = lwCreateCanvas(canvas_width, canvas_height);