# HG changeset patch # User Adam Chlipala # Date 1262290464 18000 # Node ID a5c160636832694acb479e762185175e1953df5a # Parent 72670131dace7d8a624118b4808aae8c09cb2253 Protect against NULL applications in a few places diff -r 72670131dace -r a5c160636832 src/c/urweb.c --- 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;