summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Adam Chlipala <adamc@hcoop.net>2009-12-31 15:14:24 -0500
committerGravatar Adam Chlipala <adamc@hcoop.net>2009-12-31 15:14:24 -0500
commitfc183307c2b0a05719056f022ea6d4c8385ead41 (patch)
tree372b629d794698dfe27fd5138acb771942a59c5b
parent21678b3f280cd85961e3354faecc29aab4819de4 (diff)
Protect against NULL applications in a few places
-rw-r--r--src/c/urweb.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/c/urweb.c b/src/c/urweb.c
index 3773e1fb..a54d427a 100644
--- a/src/c/urweb.c
+++ b/src/c/urweb.c
@@ -450,7 +450,7 @@ uw_context uw_init() {
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_keep_request(uw_context ctx) {
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 @@ void uw_reset(uw_context ctx) {
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;