aboutsummaryrefslogtreecommitdiff
path: root/src/pack.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/pack.c')
-rw-r--r--src/pack.c21
1 files changed, 19 insertions, 2 deletions
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.