diff options
author | Petr Machata <pmachata@redhat.com> | 2013-01-07 17:22:54 +0100 |
---|---|---|
committer | Petr Machata <pmachata@redhat.com> | 2013-03-08 22:55:31 +0100 |
commit | e56fe644f725f2c1c8308e7c2b5f9cd02e89eed0 (patch) | |
tree | a6e197848af483c330ae509438669f048ba67326 /prototype.c | |
parent | 4e553c020b0e621bc15d76296990d06e47cf29f9 (diff) | |
download | ltrace-e56fe644f725f2c1c8308e7c2b5f9cd02e89eed0.tar.gz |
Protolib cache fails when attempt is made to cache NULL
Diffstat (limited to 'prototype.c')
-rw-r--r-- | prototype.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/prototype.c b/prototype.c index f1be329..9dd1685 100644 --- a/prototype.c +++ b/prototype.c @@ -1,6 +1,6 @@ /* * This file is part of ltrace. - * Copyright (C) 2012 Petr Machata, Red Hat Inc. + * Copyright (C) 2012,2013 Petr Machata, Red Hat Inc. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as @@ -326,9 +326,9 @@ static void destroy_protolib_cb(struct protolib **plibp, void *data) { assert(plibp != NULL); - assert(*plibp != NULL); - if (--(*plibp)->refs == 0) { + if (*plibp != NULL + && --(*plibp)->refs == 0) { protolib_destroy(*plibp); free(*plibp); } @@ -629,7 +629,7 @@ protolib_cache_protolib(struct protolib_cache *cache, int rc = DICT_INSERT(&cache->protolibs, &filename, &plib); if (rc < 0 && own_filename) free((char *)filename); - if (rc == 0) + if (rc == 0 && plib != NULL) plib->refs++; return rc; } |