# HG changeset patch # User Matti Hamalainen # Date 1560721526 -10800 # Node ID 8ca515ab9c8404db51932e063dd0822f44a2d63c # Parent c146033f1f6a0a428a91dc789c3625d955e5221c Cleanups. diff -r c146033f1f6a -r 8ca515ab9c84 tools/fontconv.c --- a/tools/fontconv.c Sun Jun 16 23:31:58 2019 +0300 +++ b/tools/fontconv.c Mon Jun 17 00:45:26 2019 +0300 @@ -296,7 +296,7 @@ if (TTF_Init() < 0) { dmErrorMsg("Could not initialize FreeType/TTF: %s\n", SDL_GetError()); - goto out; + goto exit; } initTTF = TRUE; #endif @@ -306,7 +306,7 @@ { dmErrorMsg("Error opening input file '%s', %d: %s\n", optInFilename, res, dmErrorStr(res)); - return 1; + goto exit; } @@ -320,7 +320,7 @@ { dmErrorMsg("Input is a TSFONT/DMFONT font file, but there is an error: %s\n", dmErrorStr(res)); - goto out; + goto exit; } #ifdef DM_GFX_TTF_TEXT else @@ -341,7 +341,7 @@ optSplitWidth - 6, optSplitHeight + 2, optBPP)) == NULL) { dmErrorMsg("Could not allocate bitmap font!\n"); - goto out; + goto exit; } // Render glyphs from the normal ASCII range only @@ -368,7 +368,7 @@ { dmErrorMsg("Could not get TTF glyph metrics for character '%c' (%d).\n", nglyph, nglyph); - goto out; + goto exit; } dst.x = 0; @@ -395,7 +395,7 @@ if ((fontbmap = dmLoadImage(inFile)) == NULL) { dmErrorMsg("Could not load image file '%s'.\n", optInFilename); - goto out; + goto exit; } dmMsg(1, "Input is a bitmap image (%d x %d, %d bpp), splitting to %d x %d.\n", @@ -406,14 +406,14 @@ { dmErrorMsg("Could not create a font from image, %d: %s\n", res, dmErrorStr(res)); - goto out; + goto exit; } } if (font == NULL) { dmErrorMsg("No font loaded.\n"); - goto out; + goto exit; } // Count number of actually existing glyphs despite that we should have @@ -437,7 +437,7 @@ n, glyph->width, glyph->height, font->width, font->height); - goto out; + goto exit; } } } @@ -451,7 +451,7 @@ { dmErrorMsg("Error creating file '%s', %d: %s\n", optInFilename, res, dmErrorStr(res)); - goto out; + goto exit; } res = dmSaveBitmapFont(outFile, font); @@ -463,8 +463,8 @@ res, dmErrorStr(res)); } -out: - +exit: + // Cleanup #ifdef DM_GFX_TTF_TEXT if (initTTF) TTF_Quit(); @@ -472,7 +472,8 @@ dmf_close(inFile); dmFreeBitmapFont(font); - SDL_FreeSurface(fontbmap); + if (fontbmap != NULL) + SDL_FreeSurface(fontbmap); return 0; }