-No need to check if a pointer is null before freeing it.
-However if the pointer is still living (for example a global) you should assign NULL to it to avoid bad ram access and random bugs. Accessing a NULL pointer always gives a segfault, accessing a freed pointer may or may not crash. -Also fixed a memory leak git-svn-id: svn://pulkomandy.tk/GrafX2/trunk@924 416bcca6-2ee7-4201-b75f-2eb2f807beb1
This commit is contained in:
3
graph.c
3
graph.c
@@ -495,8 +495,7 @@ int Init_mode_video(int width, int height, int fullscreen, int pix_ratio)
|
||||
else if (Pixel_width>Pixel_height && Screen_height>=Menu_factor_Y*2*200)
|
||||
Menu_factor_Y*=2;
|
||||
|
||||
if (Horizontal_line_buffer)
|
||||
free(Horizontal_line_buffer);
|
||||
free(Horizontal_line_buffer);
|
||||
Horizontal_line_buffer=(byte *)malloc(Pixel_width*((Screen_width>Main_image_width)?Screen_width:Main_image_width));
|
||||
|
||||
Set_palette(Main_palette);
|
||||
|
||||
Reference in New Issue
Block a user