@@ -129,6 +129,10 @@ PrintConsole defaultConsole =
129129 256 //number of characters in the font set
130130 },
131131 (u16 * )NULL ,
132+ 0 ,0 , //con_xres con_yres
133+ 0 , //con_stride
134+ 0 ,0 , //target_x target_y
135+ 0 , //tgt_stride
132136 0 ,0 , //cursorX cursorY
133137 0 ,0 , //prevcursorX prevcursorY
134138 80 , //console width
@@ -138,9 +142,9 @@ PrintConsole defaultConsole =
138142 80 , //window width
139143 30 , //window height
140144 3 , //tab size
141- 7 , // foreground color
142- 0 , // background color
143- 0 , // flags
145+ 7 , //foreground color
146+ 0 , //background color
147+ 0 , //flags
144148 0 , //print callback
145149 false //console initialized
146150};
@@ -151,6 +155,7 @@ PrintConsole* currentConsole = ¤tCopy;
151155
152156static inline void * __console_offset_by_pixels (void * ptr , s32 dy_pixels , u32 stride_bytes , s32 dx_pixels )
153157{
158+ if (ptr == NULL ) return NULL ;
154159 const s32 dy_bytes = dy_pixels * stride_bytes ;
155160 const s32 dx_bytes = dx_pixels * VI_DISPLAY_PIX_SZ ;
156161 return (u8 * )ptr + dy_bytes + dx_bytes ;
@@ -248,6 +253,7 @@ static void __console_drawc(int c)
248253 if (c < 0 || c > con -> font .numChars ) return ;
249254
250255 ptr = __console_get_cursor_start_ptr ();
256+ if ( ptr == NULL ) return ;
251257
252258 pbits = & con -> font .gfx [c * FONT_YSIZE ];
253259 // con_stride is in bytes, but we increment ptr which is an int pointer
@@ -366,6 +372,7 @@ static void __console_clear_line(int line, int from, int to)
366372 }
367373
368374 p = __console_get_window_start_ptr ();
375+ if ( p == NULL ) return ;
369376 p = __console_offset_by_cursor (p , line , con -> con_stride , from );
370377
371378 // Clears 1 line of pixels at a time
@@ -397,6 +404,7 @@ static void __console_clear(void)
397404
398405 //get console pointer
399406 p = __console_get_window_start_ptr ();
407+ if ( p == NULL ) return ;
400408
401409 // Clears 1 line of pixels at a time
402410 for (u16 ycnt = 0 ; ycnt < view_height ; ycnt ++ )
@@ -810,6 +818,7 @@ void newRow()
810818 if ( currentConsole -> cursorY > currentConsole -> windowHeight )
811819 {
812820 u8 * ptr = __console_get_window_start_ptr ();
821+ if ( ptr == NULL ) return ;
813822
814823 // Each window line is currentConsole->windowWidth * FONT_XSIZE * VI_DISPLAY_PIX_SZ bytes wide
815824 const u32 line_width = currentConsole -> windowWidth * FONT_XSIZE * VI_DISPLAY_PIX_SZ ;
@@ -905,6 +914,7 @@ ssize_t __console_write(struct _reent *r,void *fd,const char *ptr, size_t len)
905914
906915 if (!currentConsole ) return -1 ;
907916 if (!tmp || len <=0 ) return -1 ;
917+ if ( __console_get_cursor_start_ptr () == NULL ) return -1 ;
908918
909919 while (i < len ) {
910920
0 commit comments