File tree Expand file tree Collapse file tree 1 file changed +5
-2
lines changed Expand file tree Collapse file tree 1 file changed +5
-2
lines changed Original file line number Diff line number Diff line change @@ -28,16 +28,18 @@ GLuint loadBMP_custom(const char * imagepath){
28
28
// If less than 54 bytes are read, problem
29
29
if ( fread (header, 1 , 54 , file)!=54 ){
30
30
printf (" Not a correct BMP file\n " );
31
+ fclose (file);
31
32
return 0 ;
32
33
}
33
34
// A BMP files always begins with "BM"
34
35
if ( header[0 ]!=' B' || header[1 ]!=' M' ){
35
36
printf (" Not a correct BMP file\n " );
37
+ fclose (file);
36
38
return 0 ;
37
39
}
38
40
// Make sure this is a 24bpp file
39
- if ( *(int *)&(header[0x1E ])!=0 ) {printf (" Not a correct BMP file\n " ); return 0 ;}
40
- if ( *(int *)&(header[0x1C ])!=24 ) {printf (" Not a correct BMP file\n " ); return 0 ;}
41
+ if ( *(int *)&(header[0x1E ])!=0 ) {printf (" Not a correct BMP file\n " ); fclose (file); return 0 ;}
42
+ if ( *(int *)&(header[0x1C ])!=24 ) {printf (" Not a correct BMP file\n " ); fclose (file); return 0 ;}
41
43
42
44
// Read the information about the image
43
45
dataPos = *(int *)&(header[0x0A ]);
@@ -70,6 +72,7 @@ GLuint loadBMP_custom(const char * imagepath){
70
72
71
73
// OpenGL has now copied the data. Free our own version
72
74
delete [] data;
75
+ fclose (file);
73
76
74
77
// Poor filtering, or ...
75
78
// glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
You can’t perform that action at this time.
0 commit comments