mirror of
https://github.com/nunuhara/xsystem4.git
synced 2026-09-30 02:48:14 +03:00
Fix multiple memory leaks
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user