From 74b7f537f0b7941cb8afcb2b0682a321fe62ec86 Mon Sep 17 00:00:00 2001 From: simonmar Date: Tue, 6 Feb 2001 14:44:53 +0000 Subject: [PATCH] [project @ 2001-02-06 14:44:53 by simonmar] strdup(), and later free(), the filename passed in via loadObj. Yet another bug bites the dust. --- ghc/rts/Linker.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/ghc/rts/Linker.c b/ghc/rts/Linker.c index 8b42806..73df9c0 100644 --- a/ghc/rts/Linker.c +++ b/ghc/rts/Linker.c @@ -1,5 +1,5 @@ /* ----------------------------------------------------------------------------- - * $Id: Linker.c,v 1.17 2001/02/06 12:27:57 simonmar Exp $ + * $Id: Linker.c,v 1.18 2001/02/06 14:44:53 simonmar Exp $ * * (c) The GHC Team, 2000 * @@ -383,7 +383,10 @@ loadObj( char *path ) r = stat(path, &st); if (r == -1) { return 0; } - oc->fileName = path; + /* sigh, stdup() isn't a POSIX function, so do it the long way */ + oc->fileName = stgMallocBytes( strlen(path)+1, "loadObj" ); + strcpy(oc->fileName, path); + oc->fileSize = st.st_size; oc->image = stgMallocBytes( st.st_size, "loadObj(image)" ); oc->symbols = NULL; @@ -490,6 +493,7 @@ unloadObj( char *path ) /* We're going to leave this in place, in case there are any pointers from the heap into it: */ /* free(oc->image); */ + free(oc->fileName); free(oc->symbols); free(oc->sections); free(oc); -- 1.7.10.4