From 7a49a90f8b092e1c2e58d3e754578cff3bf06b18 Mon Sep 17 00:00:00 2001 From: Adam Chlipala Date: Thu, 19 Nov 2015 10:31:47 -0500 Subject: Fix a few C memory bugs --- src/c/urweb.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'src/c/urweb.c') diff --git a/src/c/urweb.c b/src/c/urweb.c index c1cfe94c..945a6890 100644 --- a/src/c/urweb.c +++ b/src/c/urweb.c @@ -602,6 +602,8 @@ uw_context uw_init(int id, uw_loggers *lg) { ctx->remoteSock = -1; + ctx->cacheUnlock = NULL; + return ctx; } @@ -3681,7 +3683,7 @@ failure_kind uw_initialize(uw_context ctx) { if (r == 0) { uw_ensure_transaction(ctx); ctx->app->initializer(ctx); - if (ctx->app->db_commit(ctx)) + if (uw_commit(ctx)) uw_error(ctx, FATAL, "Error running SQL COMMIT"); } @@ -4626,7 +4628,7 @@ static char *uw_Sqlcache_allocKeyBuffer(char **keys, size_t numKeys) { while (numKeys-- > 0) { char* k = keys[numKeys]; if (!k) { - // Can only happen when flushihg, in which case we don't need anything past the null key. + // Can only happen when flushing, in which case we don't need anything past the null key. break; } // Leave room for separator. @@ -4695,7 +4697,7 @@ static void uw_Sqlcache_storeCommitOne(uw_Sqlcache_Cache *cache, char **keys, uw if (numKeys == 0) { entry = cache->table; if (!entry) { - entry = malloc(sizeof(uw_Sqlcache_Entry)); + entry = calloc(1, sizeof(uw_Sqlcache_Entry)); entry->key = NULL; entry->value = NULL; entry->timeInvalid = 0; @@ -4709,7 +4711,7 @@ static void uw_Sqlcache_storeCommitOne(uw_Sqlcache_Cache *cache, char **keys, uw size_t len = buf - key; entry = uw_Sqlcache_find(cache, key, len, 1); if (!entry) { - entry = malloc(sizeof(uw_Sqlcache_Entry)); + entry = calloc(1, sizeof(uw_Sqlcache_Entry)); entry->key = strdup(key); entry->value = NULL; entry->timeInvalid = 0; -- cgit v1.2.3