aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/binlog.c2
-rw-r--r--src/pack.c21
2 files changed, 21 insertions, 2 deletions
diff --git a/src/binlog.c b/src/binlog.c
index 6f438a8..b2d9f87 100644
--- a/src/binlog.c
+++ b/src/binlog.c
@@ -209,12 +209,14 @@ vmod_init(struct sess *sp, struct vmod_priv *priv,
AN(conf->dir);
conf->inst_head = packcomp(dataspec, &p);
+ AN(conf->inst_head);
if (*p) {
binlog_error("cannot compile data format near %s", p);
abort();
}
conf->recsize = packsize(conf->inst_head);
conf->env = packenv_create(conf->recsize);
+ AN(conf->env);
conf->recsize += offsetof(struct binlog_record,data);
conf->dataspec = strdup(dataspec);
AN(conf->dataspec);
diff --git a/src/pack.c b/src/pack.c
index a6ee933..5594bb1 100644
--- a/src/pack.c
+++ b/src/pack.c
@@ -432,6 +432,8 @@ packcomp(const char *s, char **endp)
if (getrep(s + 1, &s, &rep))
break;
pi = malloc(sizeof(*pi));
+ if (!pi)
+ return NULL;
pi->next = NULL;
pi->spec = ps;
pi->rep = rep;
@@ -515,8 +517,14 @@ struct packenv *
packenv_create(size_t size)
{
struct packenv *env = calloc(1, sizeof(*env));
- env->buf_base = calloc(1, size);
- env->buf_size = size;
+ if (env) {
+ env->buf_base = calloc(1, size);
+ if (!env->buf_base) {
+ free(env);
+ return NULL;
+ }
+ env->buf_size = size;
+ }
return env;
}
@@ -565,11 +573,20 @@ main(int argc, char **argv)
abort();
pi = packcomp(argv[0], &end);
+ if (!pi) {
+ fprintf(stderr, "out of memory\n");
+ abort();
+ }
if (*end) {
fprintf(stderr, "compile error near %s\n", end);
exit(1);
}
env = packenv_create(packsize(pi));
+ if (!env) {
+ fprintf(stderr, "out of memory\n");
+ abort();
+ }
+
env->fp = stdout;
env->argv = argv + 1;
env->argc = argc - 1;

Return to:

Send suggestions and report system problems to the System administrator.