Mercurial > urweb
changeset 1105:a5c160636832
Protect against NULL applications in a few places
author | Adam Chlipala <adamc@hcoop.net> |
---|---|
date | Thu, 31 Dec 2009 15:14:24 -0500 (2009-12-31) |
parents | 72670131dace |
children | c9137606733a |
files | src/c/urweb.c |
diffstat | 1 files changed, 4 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/src/c/urweb.c Thu Dec 31 11:41:57 2009 -0500 +++ b/src/c/urweb.c Thu Dec 31 15:14:24 2009 -0500 @@ -450,7 +450,7 @@ void uw_set_app(uw_context ctx, uw_app *app) { ctx->app = app; - if (app->inputs_len > ctx->sz_inputs) { + if (app && app->inputs_len > ctx->sz_inputs) { ctx->sz_inputs = app->inputs_len; ctx->inputs = realloc(ctx->inputs, ctx->sz_inputs * sizeof(input)); memset(ctx->inputs, 0, ctx->sz_inputs * sizeof(input)); @@ -512,7 +512,8 @@ void uw_reset(uw_context ctx) { uw_reset_keep_request(ctx); - memset(ctx->inputs, 0, ctx->app->inputs_len * sizeof(input)); + if (ctx->app) + memset(ctx->inputs, 0, ctx->app->inputs_len * sizeof(input)); memset(ctx->subinputs, 0, ctx->n_subinputs * sizeof(input)); ctx->used_subinputs = 0; } @@ -520,7 +521,7 @@ failure_kind uw_begin_init(uw_context ctx) { int r = setjmp(ctx->jmp_buf); - if (r == 0) + if (r == 0 && ctx->app) ctx->app->db_init(ctx); return r;