summaryrefslogtreecommitdiff
path: root/uisimulator
diff options
context:
space:
mode:
Diffstat (limited to 'uisimulator')
-rw-r--r--uisimulator/bmp.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/uisimulator/bmp.c b/uisimulator/bmp.c
index 404869fcf2..85a0fd2ffe 100644
--- a/uisimulator/bmp.c
+++ b/uisimulator/bmp.c
@@ -122,6 +122,7 @@ int read_bmp_file(char* filename,
122 sizeof(struct Fileheader)) 122 sizeof(struct Fileheader))
123 { 123 {
124 debugf("error - can't Read Fileheader Stucture\n"); 124 debugf("error - can't Read Fileheader Stucture\n");
125 close(fd);
125 return 2; 126 return 2;
126 } 127 }
127 128
@@ -130,6 +131,7 @@ int read_bmp_file(char* filename,
130 { 131 {
131 debugf("error - Bitmap must be less than 8, got %d\n", 132 debugf("error - Bitmap must be less than 8, got %d\n",
132 readshort(fh.BitCount)); 133 readshort(fh.BitCount));
134 close(fd);
133 return 2; 135 return 2;
134 } 136 }
135 137
@@ -138,6 +140,7 @@ int read_bmp_file(char* filename,
138 { 140 {
139 debugf("error - Bitmap is too wide (%d pixels, max is 112)\n", 141 debugf("error - Bitmap is too wide (%d pixels, max is 112)\n",
140 readlong(fh.Width)); 142 readlong(fh.Width));
143 close(fd);
141 return 3; 144 return 3;
142 } 145 }
143 debugf("Bitmap is %d pixels wide\n", readlong(fh.Width)); 146 debugf("Bitmap is %d pixels wide\n", readlong(fh.Width));
@@ -147,6 +150,7 @@ int read_bmp_file(char* filename,
147 { 150 {
148 debugf("error - Bitmap is too high (%d pixels, max is 64)\n", 151 debugf("error - Bitmap is too high (%d pixels, max is 64)\n",
149 readlong(fh.Height)); 152 readlong(fh.Height));
153 close(fd);
150 return 4; 154 return 4;
151 } 155 }
152 debugf("Bitmap is %d pixels heigh\n", readlong(fh.Height)); 156 debugf("Bitmap is %d pixels heigh\n", readlong(fh.Height));
@@ -157,6 +161,7 @@ int read_bmp_file(char* filename,
157 sizeof(struct RGBQUAD)) 161 sizeof(struct RGBQUAD))
158 { 162 {
159 debugf("error - Can't read bitmap's color palette\n"); 163 debugf("error - Can't read bitmap's color palette\n");
164 close(fd);
160 return 5; 165 return 5;
161 } 166 }
162 } 167 }
@@ -192,12 +197,14 @@ int read_bmp_file(char* filename,
192 if(bmp == NULL) 197 if(bmp == NULL)
193 { 198 {
194 debugf("error - Out of memory\n"); 199 debugf("error - Out of memory\n");
200 close(fd);
195 return 6; 201 return 6;
196 } 202 }
197 else 203 else
198 { 204 {
199 if(read(fd, (unsigned char*)bmp,(long)size) != size) { 205 if(read(fd, (unsigned char*)bmp,(long)size) != size) {
200 debugf("error - Can't read image\n"); 206 debugf("error - Can't read image\n");
207 close(fd);
201 return 7; 208 return 7;
202 } 209 }
203 } 210 }
@@ -249,6 +256,7 @@ int read_bmp_file(char* filename,
249 256
250#endif 257#endif
251 } 258 }
259 close(fd);
252 return 0; /* success */ 260 return 0; /* success */
253} 261}
254 262