From 247013bb5cb39d05716afdba6fdbdbe985082bf2 Mon Sep 17 00:00:00 2001
From: Christophe Fergeau <teuf@gnome.org>
Date: Mon, 13 Dec 2010 23:39:01 +0100
Subject: [PATCH 3/3] don't return a local variable from get_from_cache

get_from_cache was reading cache data into a local char[] allocated
on the stack, and was returning the address of this local variable
to the caller. strdup the string before returning it. However this
leaks memory since I didn't review the call sites (but the program
is short lived so it should be acceptable).
---
 src/cache.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/src/cache.c b/src/cache.c
index 750e20d..f50cd87 100755
--- a/src/cache.c
+++ b/src/cache.c
@@ -119,7 +119,7 @@ char* get_from_cache(const char *what)
 	char d[BUFSIZE];
 	read_file((const char *)fname, d);
 
-	return (char *)d;
+	return strdup(d);
 }
 
 /* Just prints a little notice about what caching actually does... */
-- 
1.7.3.3

