vbscript: Don't leak memory in parser.

oldstable
Jacek Caban 2011-09-12 12:29:31 +02:00 committed by Alexandre Julliard
parent 5b8cde66f1
commit bb80eaa492
2 changed files with 11 additions and 2 deletions

View File

@ -87,8 +87,11 @@ typedef struct {
statement_t *stats;
statement_t *stats_tail;
vbsheap_t heap;
} parser_ctx_t;
HRESULT parse_script(parser_ctx_t*,const WCHAR*) DECLSPEC_HIDDEN;
void parser_release(parser_ctx_t*) DECLSPEC_HIDDEN;
int parser_lex(void*,parser_ctx_t*) DECLSPEC_HIDDEN;
void *parser_alloc(parser_ctx_t*,size_t) DECLSPEC_HIDDEN;

View File

@ -280,8 +280,7 @@ void *parser_alloc(parser_ctx_t *ctx, size_t size)
{
void *ret;
/* FIXME: leaks! */
ret = heap_alloc(size);
ret = vbsheap_alloc(&ctx->heap, size);
if(!ret)
ctx->hres = E_OUTOFMEMORY;
return ret;
@ -292,6 +291,8 @@ HRESULT parse_script(parser_ctx_t *ctx, const WCHAR *code)
ctx->code = ctx->ptr = code;
ctx->end = ctx->code + strlenW(ctx->code);
vbsheap_init(&ctx->heap);
ctx->parse_complete = FALSE;
ctx->hres = S_OK;
@ -311,3 +312,8 @@ HRESULT parse_script(parser_ctx_t *ctx, const WCHAR *code)
return S_OK;
}
void parser_release(parser_ctx_t *ctx)
{
vbsheap_free(&ctx->heap);
}