aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/c/urweb.c
diff options
context:
space:
mode:
authorGravatar Adam Chlipala <adam@chlipala.net>2015-11-19 10:31:47 -0500
committerGravatar Adam Chlipala <adam@chlipala.net>2015-11-19 10:31:47 -0500
commit7a49a90f8b092e1c2e58d3e754578cff3bf06b18 (patch)
tree241c66d172a00cfee919a4e4aee49393fc792d42 /src/c/urweb.c
parent0c231060050adf556348b06f078c994f4a0e65b4 (diff)
Fix a few C memory bugs
Diffstat (limited to 'src/c/urweb.c')
-rw-r--r--src/c/urweb.c10
1 files changed, 6 insertions, 4 deletions
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;