From ea5866863cbdad80eb69351417018c6104c5f43b Mon Sep 17 00:00:00 2001 From: Helmut Grohne Date: Tue, 19 Jan 2010 20:33:25 +0100 Subject: fixed a few memory leaks --- src/map/magic-interpreter-parser.y | 2 ++ src/map/magic-stmt.c | 4 +++- src/map/script.c | 4 +--- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/map/magic-interpreter-parser.y b/src/map/magic-interpreter-parser.y index 047e38c..04d5630 100644 --- a/src/map/magic-interpreter-parser.y +++ b/src/map/magic-interpreter-parser.y @@ -268,6 +268,8 @@ spellconf_option : ID '=' expr if (!failed_flag) add_teleport_anchor(anchor, @1.first_line); + else + free(anchor); failed_flag = 0; } | PROCEDURE ID '(' proc_formals_list ')' '=' effect_list diff --git a/src/map/magic-stmt.c b/src/map/magic-stmt.c index 1a1ced7..93ef65f 100644 --- a/src/map/magic-stmt.c +++ b/src/map/magic-stmt.c @@ -1161,7 +1161,7 @@ static effect_t *run_foreach (invocation_t * invocation, effect_t * foreach, cont_activation_record_t *ar = add_stack_entry (invocation, CONT_STACK_FOREACH, return_location); int entities_allocd = 64; - int *entities_collect = malloc (entities_allocd * sizeof (int)); + int *entities_collect; int *entities; int *shuffle_board; int entities_nr = 0; @@ -1170,6 +1170,8 @@ static effect_t *run_foreach (invocation_t * invocation, effect_t * foreach, if (!ar) return return_location; + entities_collect = malloc (entities_allocd * sizeof (int)); + find_entities_in_area (area.v.v_area, &entities_allocd, &entities_nr, &entities_collect, filter); diff --git a/src/map/script.c b/src/map/script.c index 03a092e..0ede96c 100644 --- a/src/map/script.c +++ b/src/map/script.c @@ -6264,7 +6264,6 @@ int buildin_strmobinfo (struct script_state *st) if (num == 1) { char *buf; - buf = calloc (24, 1); buf = mob_db[class].name; push_str (st->stack, C_STR, buf); return 0; @@ -6272,7 +6271,6 @@ int buildin_strmobinfo (struct script_state *st) else if (num == 2) { char *buf; - buf = calloc (24, 1); buf = mob_db[class].jname; push_str (st->stack, C_STR, buf); return 0; @@ -6938,13 +6936,13 @@ int buildin_getsavepoint (struct script_state *st) sd = script_rid2sd (st); type = conv_num (st, &(st->stack->stack_data[st->start + 2])); - mapname = calloc (24, 1); x = sd->status.save_point.x; y = sd->status.save_point.y; switch (type) { case 0: + mapname = calloc (24, 1); strncpy (mapname, sd->status.save_point.map, 23); push_str (st->stack, C_STR, mapname); break; -- cgit v1.2.3-60-g2f50