aboutsummaryrefslogtreecommitdiff
path: root/driver-ti.c
diff options
context:
space:
mode:
authorPaul LeoNerd Evans <leonerd@leonerd.org.uk>2008-10-09 23:19:10 +0100
committerPaul LeoNerd Evans <leonerd@leonerd.org.uk>2008-10-09 23:19:10 +0100
commit2b08f88f19b0270c9db993c940181535c33a71b3 (patch)
treee18ccfa2bd77c894a652ea20192cc778576ca5c2 /driver-ti.c
parent286532e6021f1a1a90966a8ecf683d9efc5ec55d (diff)
downloadtermo-2b08f88f19b0270c9db993c940181535c33a71b3.tar.gz
termo-2b08f88f19b0270c9db993c940181535c33a71b3.tar.xz
termo-2b08f88f19b0270c9db993c940181535c33a71b3.zip
Better free() tracking in constructor failure cases
Diffstat (limited to 'driver-ti.c')
-rw-r--r--driver-ti.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/driver-ti.c b/driver-ti.c
index 66cdbe7..00090bd 100644
--- a/driver-ti.c
+++ b/driver-ti.c
@@ -33,6 +33,8 @@ static void *new_driver(termkey_t *tk, const char *term)
return NULL;
termkey_ti *ti = malloc(sizeof *ti);
+ if(!ti)
+ return NULL;
ti->tk = tk;
@@ -40,6 +42,8 @@ static void *new_driver(termkey_t *tk, const char *term)
ti->nseqs = 0;
ti->seqs = malloc(ti->alloced_seqs * sizeof(ti->seqs[0]));
+ if(!ti->seqs)
+ goto abort_free_ti;
int i;
for(i = 0; strfnames[i]; i++) {
@@ -64,6 +68,11 @@ static void *new_driver(termkey_t *tk, const char *term)
}
return ti;
+
+abort_free_ti:
+ free(ti);
+
+ return NULL;
}
static void free_driver(void *private)