diff options
Diffstat (limited to 'src/posix/lposix.c')
-rw-r--r-- | src/posix/lposix.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/src/posix/lposix.c b/src/posix/lposix.c index 77fa761..52908d8 100644 --- a/src/posix/lposix.c +++ b/src/posix/lposix.c @@ -110,6 +110,8 @@ static int compile_regex (lua_State *L, const TArgComp *argC, TPosix **pud) { if (argC->cflags & REG_NOSUB) ud->r.re_nsub = 0; ud->match = (regmatch_t *) Lmalloc (L, (ALG_NSUB(ud) + 1) * sizeof (regmatch_t)); + if (!ud->match) + luaL_error (L, "malloc failed"); lua_pushvalue (L, ALG_ENVIRONINDEX); lua_setmetatable (L, -2); @@ -184,7 +186,7 @@ static int Posix_gc (lua_State *L) { if (ud->freed == 0) { /* precaution against "manual" __gc calling */ ud->freed = 1; regfree (&ud->r); - free (ud->match); + Lfree (L, ud->match, (ALG_NSUB(ud) + 1) * sizeof (regmatch_t)); } return 0; } |