Skip to content

Commit 4a46573

Browse files
committed
fixes #22
1 parent e2d13a0 commit 4a46573

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

common/texture.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,16 +28,18 @@ GLuint loadBMP_custom(const char * imagepath){
2828
// If less than 54 bytes are read, problem
2929
if ( fread(header, 1, 54, file)!=54 ){
3030
printf("Not a correct BMP file\n");
31+
fclose(file);
3132
return 0;
3233
}
3334
// A BMP files always begins with "BM"
3435
if ( header[0]!='B' || header[1]!='M' ){
3536
printf("Not a correct BMP file\n");
37+
fclose(file);
3638
return 0;
3739
}
3840
// 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;}
4143

4244
// Read the information about the image
4345
dataPos = *(int*)&(header[0x0A]);
@@ -70,6 +72,7 @@ GLuint loadBMP_custom(const char * imagepath){
7072

7173
// OpenGL has now copied the data. Free our own version
7274
delete [] data;
75+
fclose(file);
7376

7477
// Poor filtering, or ...
7578
//glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);

0 commit comments

Comments
 (0)