diff options
author | Paul LeoNerd Evans <leonerd@leonerd.org.uk> | 2008-10-09 23:19:10 +0100 |
---|---|---|
committer | Paul LeoNerd Evans <leonerd@leonerd.org.uk> | 2008-10-09 23:19:10 +0100 |
commit | 2b08f88f19b0270c9db993c940181535c33a71b3 (patch) | |
tree | e18ccfa2bd77c894a652ea20192cc778576ca5c2 /driver-csi.c | |
parent | 286532e6021f1a1a90966a8ecf683d9efc5ec55d (diff) | |
download | termo-2b08f88f19b0270c9db993c940181535c33a71b3.tar.gz termo-2b08f88f19b0270c9db993c940181535c33a71b3.tar.xz termo-2b08f88f19b0270c9db993c940181535c33a71b3.zip |
Better free() tracking in constructor failure cases
Diffstat (limited to 'driver-csi.c')
-rw-r--r-- | driver-csi.c | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/driver-csi.c b/driver-csi.c index be709a3..3803c30 100644 --- a/driver-csi.c +++ b/driver-csi.c @@ -37,6 +37,8 @@ static void *new_driver(termkey_t *tk, const char *term) // Excellent - we'll continue termkey_csi *csi = malloc(sizeof *csi); + if(!csi) + return NULL; csi->tk = tk; @@ -51,6 +53,8 @@ static void *new_driver(termkey_t *tk, const char *term) csi->ncsifuncs = 32; csi->csifuncs = malloc(sizeof(csi->csifuncs[0]) * csi->ncsifuncs); + if(!csi->csifuncs) + goto abort_free_csi; for(i = 0; i < csi->ncsifuncs; i++) csi->csifuncs[i].sym = TERMKEY_SYM_UNKNOWN; @@ -119,6 +123,11 @@ static void *new_driver(termkey_t *tk, const char *term) register_csifunc(csi, TERMKEY_TYPE_FUNCTION, 20, 34, NULL); return csi; + +abort_free_csi: + free(csi); + + return NULL; } static void free_driver(void *private) |