int bmp2lcd (char *bildfile)
{
- char bild2lcd [50];
char filename[50];
char bmpfile[50];
}
if (fread(&bh, 1, sizeof(bh), fbmp)!=sizeof(bh)) {
perror("fread(BMP_HEADER)");
+ fclose(fbmp);
return(3);
}
if ((bh._B!='B')||(bh._M!='M')) {
fprintf(stderr, "Bad Magic (not a BMP file).\n");
+ fclose(fbmp);
return(4);
}
colors = malloc(4<<bh.bit_count);
if (fread(colors, 1, 4<<bh.bit_count, fbmp)!=4<<bh.bit_count) {
perror("fread(BMP_COLORS)");
+ fclose(fbmp);
+ if(colors)
+ free(colors);
return(5);
}
-
+ if(colors)
+ free(colors);
// image
line_size = (bh.width*bh.bit_count / 8);
bmpline_size = (line_size + 3) & ~3;
image = malloc(image_size);
if (fread(image, 1, image_size, fbmp)!=image_size) {
perror("fread(BMP_IMAGE)");
+ fclose(fbmp);
+ if(image)
+ free(image);
return(6);
}
fclose(fbmp);
printf("WARNING: Image is compressed - result unpredictable.\n");
bmp2raw(bh, image, raw);
+ if(image)
+ free(image);
raw2packed(raw, s);
if(lcd_fd < 0)
-arm-cx2450x-linux-gnueabi-gcc -g -o tuxwetter tuxwetter.c gfx.c io.c text.c parser.c php.c http.c jpeg.c fb_display.c resize.c pngw.c gif.c -L$PREFIX/lib -I$PREFIX/include -I$PREFIX/include/freetype2 -O2 -lfreetype -lz -ljpeg -lpng -lgif -DWWEATHER gifdecomp.c
+arm-cx2450x-linux-gnueabi-gcc -g -o tuxwetter tuxwetter.c gfx.c io.c text.c parser.c php.c http.c jpeg.c fb_display.c resize.c pngw.c gif.c -L$PREFIX/lib -I$PREFIX/include -I$PREFIX/include/freetype2 -O2 -lfreetype -lcurl -lz -ljpeg -lpng -lungif -DWWEATHER gifdecomp.c
if(!(fh=fopen(name,"rb"))) return(FH_ERROR_FILE);
png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING,NULL,NULL,NULL);
- if(png_ptr == NULL) return(FH_ERROR_FORMAT);
+ if(png_ptr == NULL) {
+ fclose(fh);
+ return(FH_ERROR_FORMAT);
+ }
info_ptr = png_create_info_struct(png_ptr);
if(info_ptr == NULL)
{
if(!(fh=fopen(name,"rb"))) return(FH_ERROR_FILE);
png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING,NULL,NULL,NULL);
- if(png_ptr == NULL) return(FH_ERROR_FORMAT);
+ if(png_ptr == NULL) {
+ fclose(fh);
+ return(FH_ERROR_FORMAT);
+ }
info_ptr = png_create_info_struct(png_ptr);
if(info_ptr == NULL)
{
*/
}
}
-
+ if(fd_conf)
+ fclose(fd_conf);
return 1;
}
if(fh_png_getsize(ICON_FILE, &x1, &y1, xsize, ysize))
{
printf("Tuxwetter <invalid PNG-Format>\n");
+ fclose(tfh);
return -1;
}
#else
if(fh_gif_getsize(ICON_FILE, &x1, &y1, xsize, ysize))
{
printf("Tuxwetter <invalid GIF-Format>\n");
+ fclose(tfh);
return -1;
}
#endif
if((buffer=(unsigned char *) malloc(x1*y1*4))==NULL)
{
printf(NOMEM);
+ fclose(tfh);
return -1;
}
#ifdef WWEATHER
}
free(buffer);
+ fclose(tfh);
lfb=tbuf;
}
return (rv)?-1:0;