Fix multiple memory leaks

This commit is contained in:
Nunuhara Cabbage
2019-12-25 22:23:20 -08:00
parent eb8c7b0fe6
commit 084634c2fc
4 changed files with 11 additions and 0 deletions
+4
View File
@@ -41,8 +41,10 @@ hll_defun(Load, args)
if (!(fp = fopen(path, "rb"))) {
WARNING("ACXLoader.Load: Failed to open %s", path);
free(path);
hll_return(false);
}
free(path);
// get size of ACX file
fseek(fp, 0, SEEK_END);
@@ -67,6 +69,7 @@ hll_defun(Load, args)
unsigned long size = acx.size;
if (Z_OK != uncompress(acx.data_raw, &size, buf+16, len-16)) {
WARNING("ACXLoader.Load: uncompress failed");
free(buf);
hll_return(false);
}
@@ -74,6 +77,7 @@ hll_defun(Load, args)
acx.nr_lines = LittleEndian_getDW(acx.data_raw, 4 + acx.nr_columns * 4);
acx.data = acx.data_raw + (8 + acx.nr_columns * 4);
free(buf);
hll_return(true);
}
+4
View File
@@ -65,6 +65,8 @@ hll_defun(Close, args)
}
int r = !fclose(current_file);
current_file = NULL;
if (file_contents)
free(file_contents);
file_contents = NULL;
file_size = 0;
file_cursor = 0;
@@ -168,8 +170,10 @@ hll_defun(GetTime, args)
if (stat(path, &s) < 0) {
WARNING("stat failed: %s", strerror(errno));
free(path);
hll_return(0);
}
free(path);
struct tm *tm = localtime(&s.st_mtime);
if (!tm) {
+2
View File
@@ -333,6 +333,7 @@ void gfx_draw_text_to_amap(Texture *dst, int x, int y, char *text)
get_glyph(font->font, &glyph, conv, font_metrics.color);
render_glyph(dst, &glyph, pos);
gfx_delete_texture(&glyph);
free(conv);
glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ZERO);
}
@@ -354,6 +355,7 @@ void gfx_draw_text_to_pmap(Texture *dst, int x, int y, char *text)
get_glyph(font->font, &glyph, conv, font_metrics.color);
render_glyph(dst, &glyph, pos);
gfx_delete_texture(&glyph);
free(conv);
glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ZERO);
}
+1
View File
@@ -79,6 +79,7 @@ static GLuint load_shader_file(const char *path, GLenum type)
glGetShaderiv(shader, GL_COMPILE_STATUS, &shader_compiled);
if (!shader_compiled)
ERROR("Failed to compile shader: %s", path);
free((char*)source);
return shader;
}