]> Chaos Git - corbenik/corbenik.git/commitdiff
Fixed memory leaking, clarified calculation precedence 32/head
authorudemiko <umikaze@protonmail.ch>
Sat, 20 Aug 2016 16:34:11 +0000 (18:34 +0200)
committerudemiko <umikaze@protonmail.ch>
Sat, 20 Aug 2016 19:11:20 +0000 (21:11 +0200)
source/config-file.c
source/std/draw.c
source/std/fs.c

index 789d40f21ee09f6e915c69fb320586c19066b18a..cb0bc9c5344c1306097b62b5da2783d1886f22b6 100644 (file)
@@ -112,6 +112,7 @@ load_config()
         config = (struct config_file*)malloc(sizeof(struct config_file) + FCRAM_SPACING / 2);
         memset(config, 0, sizeof(struct config_file) + FCRAM_SPACING / 2);
         enable_list = (uint8_t*)config + sizeof(struct config_file);
+        fclose(f);
     }
 
     // Zero on success.
index efbb6e0936a9010c0ae58cf74e1f930046758ac4..b57532e51e92f0fde0e593095fbb411c00e9a767 100644 (file)
@@ -190,7 +190,7 @@ void set_font(const char* filename) {
         abort("Invalid font file: w/h is 0 - not loaded\n");
     }
 
-    unsigned int c_font_w = (new_w / 8) + (new_w % 8 ? 1 : 0);
+    unsigned int c_font_w = (new_w / 8) + ((new_w % 8) ? 1 : 0);
 
     font_data = malloc(c_font_w * new_h * (256 - ' '));
 
@@ -307,7 +307,7 @@ draw_character(uint8_t *screen, const unsigned int character, unsigned int ch_x,
     if (x >= width || y >= height)
         return; // OOB
 
-    unsigned int c_font_w = (font_w / 8) + (font_w % 8 ? 1 : 0);
+    unsigned int c_font_w = (font_w / 8) + ((font_w % 8) ? 1 : 0);
 
     for (unsigned int yy = 0; yy < font_h; yy++) {
         unsigned int xDisplacement   = (x * SCREEN_DEPTH * height);
index 814d09ed7277a2bab26d9a562338cd8af93f7e73..7bc4dd8f3db39055a9584de9074b7550bf9c9265 100644 (file)
@@ -101,8 +101,10 @@ fopen(const char *filename, const char *mode)
 
     fp->mode = (mode[0] == 'r' ? FA_READ : (FA_WRITE | FA_OPEN_ALWAYS));
 
-    if (f_open(&(fp->handle), filename, fp->mode))
+    if (f_open(&(fp->handle), filename, fp->mode)) {
+        free(fp);
         return NULL;
+      }
 
     fp->is_open = 1;