@@ -158,7 +158,10 @@ void LCDText::TextBlit(int row, int col, int height,
158158 int dr, dc; /* display row/col */
159159 int p1, p2; /* start/end positon of changed area */
160160 int eq; /* counter for equal contents */
161- char fb[LROWS * LCOLS];
161+ char * const fb = new char [LROWS * LCOLS];
162+
163+ if (!fb)
164+ return ;
162165
163166 memset (fb, ' ' , LROWS * LCOLS);
164167 for (int r = row; r < LROWS && r < row + height; r++) {
@@ -207,6 +210,8 @@ void LCDText::TextBlit(int row, int col, int height,
207210 DisplayFB + dr * DCOLS + p1, p2 - p1 + 1 );
208211 }
209212 }
213+
214+ delete [] fb;
210215}
211216
212217void LCDText::CleanBuffer (unsigned char **buf) {
@@ -769,7 +774,11 @@ void LCDText::TransitionLeftRight() {
769774 int direction = visitor_->GetDirection ();
770775 int col;
771776 unsigned char *left, *right;
772- unsigned char layout[LROWS * LCOLS], transition[LROWS * LCOLS];
777+ unsigned char * const layout = new unsigned char [LROWS * LCOLS];
778+ unsigned char * const transition = new unsigned char [LROWS * LCOLS];
779+
780+ if (!layout || !transition)
781+ return ;
773782
774783 // Hide last layout's special chars if new layout has special chars.
775784 for (int l = 0 ; special_chars.size () > 0 && l < LAYERS; l++) {
@@ -827,14 +836,21 @@ void LCDText::TransitionLeftRight() {
827836 }
828837 TextBlit (0 , 0 , LROWS, LCOLS);
829838 }
839+
840+ delete [] layout;
841+ delete [] transition;
830842}
831843
832844void LCDText::TransitionUpDown () {
833845
834846 int direction = visitor_->GetDirection ();
835847 int row;
836848 unsigned char *top, *bottom;
837- unsigned char layout[LROWS * LCOLS], transition[LROWS * LCOLS];
849+ unsigned char * const layout = new unsigned char [LROWS * LCOLS];
850+ unsigned char * const transition = new unsigned char [LROWS * LCOLS];
851+
852+ if (!layout || !transition)
853+ return ;
838854
839855 // Hide last layout's special chars if new layout has special chars.
840856 for (int l = LAYERS - 1 ; l>=0 ; l--) {
@@ -884,6 +900,9 @@ void LCDText::TransitionUpDown() {
884900 }
885901 TextBlit (0 , 0 , LROWS, LCOLS);
886902 }
903+
904+ delete [] layout;
905+ delete [] transition;
887906}
888907
889908void SaneCoords (LCDText *lcd, int *x, int *y1, int *y2) {
@@ -929,7 +948,10 @@ void LCDText::TransitionTentacle() {
929948 double multiplier = 0 ;
930949 double multiadd = 1.0 / LCOLS;
931950 double rate = (LCOLS - transition_tick_) / (double )LCOLS;
932- unsigned char layout[LCOLS * LROWS];
951+ unsigned char * const layout = new unsigned char [LCOLS * LROWS];
952+
953+ if (!layout)
954+ return ;
933955
934956 memset (DisplayFB, (int )' ' , LCOLS * LROWS);
935957 memset (layout, (int )' ' , LCOLS * LROWS);
@@ -982,6 +1004,8 @@ void LCDText::TransitionTentacle() {
9821004 }
9831005 TextBlit (0 , 0 , LROWS, LCOLS);
9841006 }
1007+
1008+ delete [] layout;
9851009}
9861010
9871011void LCDText::TransitionCheckerBoard () {
0 commit comments