summaryrefslogtreecommitdiff
path: root/src/c
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
commit7c4572e3a03a06822a27345b1b44cdeb0087a950 (patch)
tree372b629d794698dfe27fd5138acb771942a59c5b /src/c
parentd92155463bff760184418a3d282730841c9e3b7f (diff)
Protect against NULL applications in a few places
Diffstat (limited to 'src/c')
-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;