diff options
author | dimitri staessens <dimitri.staessens@ugent.be> | 2017-10-23 17:47:52 +0200 |
---|---|---|
committer | Sander Vrijders <sander.vrijders@ugent.be> | 2017-10-23 18:19:18 +0200 |
commit | 3d9501007a24bf5422335238960f6777d2684d35 (patch) | |
tree | 22326bbba7109b0adab59b1f4e18c59aedd23ddd | |
parent | 2b1f71e7993070cbc8b37d44a44d8c6554ef0631 (diff) | |
download | ouroboros-3d9501007a24bf5422335238960f6777d2684d35.tar.gz ouroboros-3d9501007a24bf5422335238960f6777d2684d35.zip |
lib: Fix exit bug in dev.c
If the library init() fails, the fini() call tries to access
unreleased resources. The fix resets the ai struct to 0 if init()
fails and checks a heap pointer for NULL before the fini() accesses
internals.
Signed-off-by: dimitri staessens <dimitri.staessens@ugent.be>
Signed-off-by: Sander Vrijders <sander.vrijders@ugent.be>
-rw-r--r-- | src/lib/dev.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/src/lib/dev.c b/src/lib/dev.c index 85dbfb0a..e216baab 100644 --- a/src/lib/dev.c +++ b/src/lib/dev.c @@ -713,6 +713,7 @@ __attribute__((constructor)) static void init(int argc, fail_fds: fprintf(stderr, "FATAL: ouroboros-dev init failed. " "Make sure an IRMd is running.\n\n"); + memset(&ai, 0, sizeof(ai)); exit(EXIT_FAILURE); } @@ -720,6 +721,9 @@ __attribute__((destructor)) static void fini(void) { int i = 0; + if (ai.fds == NULL) + return; + bmp_destroy(ai.fds); bmp_destroy(ai.fqueues); |