[ltrace-commits] 02/02: Fix a memory leak in protolib_cache_maybe_load

Petr Machata pmachata-guest at moszumanska.debian.org
Tue Apr 21 15:05:43 UTC 2015


This is an automated email from the git hooks/post-receive script.

pmachata-guest pushed a commit to branch master
in repository ltrace.

commit 7efaa1ff812fef0bbbaffac3d620d7b7b5d6988c
Author: Роман Донченко <dpb at corrigendum.ru>
Date:   Mon Apr 20 03:39:22 2015 +0300

    Fix a memory leak in protolib_cache_maybe_load
    
    When a non-NULL protolib is returned and own_key is true, the key must
    be freed.
---
 prototype.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/prototype.c b/prototype.c
index 1383433..b09f945 100644
--- a/prototype.c
+++ b/prototype.c
@@ -547,8 +547,11 @@ protolib_cache_maybe_load(struct protolib_cache *cache,
 			  const char *key, int own_key, bool allow_private,
 			  struct protolib **retp)
 {
-	if (DICT_FIND_VAL(&cache->protolibs, &key, retp) == 0)
+	if (DICT_FIND_VAL(&cache->protolibs, &key, retp) == 0) {
+		if (*retp != NULL && own_key)
+			free((void *) key);
 		return 0;
+	}
 
 	if (strdup_if(&key, key, !own_key) < 0) {
 		fprintf(stderr, "Couldn't cache %s: %s\n",

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/collab-maint/ltrace.git



More information about the ltrace-commits mailing list