-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:
Adrien Destugues
2009-07-16 07:33:14 +00:00
parent 8b5681eccb
commit 07bfc119b8
3 changed files with 14 additions and 18 deletions

View File

@@ -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);