diff options
| -rw-r--r-- | Lua/lbp.c | 6 | ||||
| -rw-r--r-- | match.c | 6 | ||||
| -rw-r--r-- | match.h | 2 |
3 files changed, 8 insertions, 6 deletions
@@ -33,9 +33,11 @@ static void push_match(lua_State *L, match_t *m, const char *start); lua_State *cur_state = NULL; -static void match_error(const char *msg) +static void match_error(char **msg) { - lua_pushstring(cur_state, msg); + lua_pushstring(cur_state, *msg); + free(*msg); + *msg = NULL; lua_error(cur_state); } @@ -51,8 +51,8 @@ typedef struct match_ctx_s { static match_t *unused_matches = NULL; static match_t *in_use_matches = NULL; -static void default_error_handler(const char *msg) { - errx(EXIT_FAILURE, "%s", msg); +static void default_error_handler(char **msg) { + errx(EXIT_FAILURE, "%s", *msg); } static bp_errhand_t error_handler = default_error_handler; @@ -881,7 +881,7 @@ bool next_match(match_t **m, const char *start, const char *end, pat_t *pat, pat cache_destroy(&ctx); *m = NULL; if (error_handler) - error_handler(error_message); + error_handler(&error_message); if (error_message) { free(error_message); @@ -25,7 +25,7 @@ typedef struct match_s { struct match_s *_children[3]; } match_t; -typedef void (*bp_errhand_t)(const char *err_msg); +typedef void (*bp_errhand_t)(char **err_msg); __attribute__((nonnull)) void recycle_match(match_t **at_m); |
