From 6b2d40b0d5d62546fe0676c8268ca7857a41815c Mon Sep 17 00:00:00 2001 From: jonas Date: Tue, 19 Feb 2019 02:10:41 +0100 Subject: Fixed picture flipping + memory leaks --- bitmap.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'bitmap.c') diff --git a/bitmap.c b/bitmap.c index 3ca2236..11554e7 100644 --- a/bitmap.c +++ b/bitmap.c @@ -20,6 +20,7 @@ struct bitmap_pixel_data bitmap_read(char *_file) struct bitmap_file_header header; ret.R = ret.G = ret.B = NULL; + ret.error = 1; FILE *bitmap = fopen(_file,"r"); @@ -41,6 +42,7 @@ struct bitmap_pixel_data bitmap_read(char *_file) fclose(bitmap); + ret.error = 0; return ret; } @@ -129,7 +131,7 @@ struct bitmap_pixel_data bitmap_read_pixel_data(FILE *_file, struct bitmap_file_ ret.R = malloc(sizeof(*ret.R) * ret.x); ret.G = malloc(sizeof(*ret.G) * ret.x); ret.B = malloc(sizeof(*ret.B) * ret.x); - for(int i = 0; i < ret.y; i++) + for(int i = 0; i < ret.x; i++) { ret.R[i] = malloc(sizeof(*ret.R[i]) * ret.y); ret.G[i] = malloc(sizeof(*ret.G[i]) * ret.y); -- cgit v1.2.3