diff --git a/lib/progreloc.c b/lib/progreloc.c index ac9433b..89bc868 100644 --- a/lib/progreloc.c +++ b/lib/progreloc.c @@ -290,8 +290,11 @@ prepare_relocate (const char *orig_installprefix, const char *orig_installdir, curr_prefix = compute_curr_prefix (orig_installprefix, orig_installdir, executable_fullname); if (curr_prefix != NULL) - /* Now pass this prefix to all copies of the relocate.c source file. */ - set_relocation_prefix (orig_installprefix, curr_prefix); + { + /* Now pass this prefix to all copies of the relocate.c source file. */ + set_relocation_prefix (orig_installprefix, curr_prefix); + free(curr_prefix); + } } /* Set program_name, based on argv[0], and original installation prefix and diff --git a/lib/relocatable.c b/lib/relocatable.c index 5e1dde6..6ebb891 100644 --- a/lib/relocatable.c +++ b/lib/relocatable.c @@ -254,8 +254,11 @@ compute_curr_prefix (const char *orig_installprefix, } if (rp > rel_installdir) - /* Unexpected: The curr_installdir does not end with rel_installdir. */ - return NULL; + { + /* Unexpected: The curr_installdir does not end with rel_installdir. */ + free((char*)curr_installdir); + return NULL; + } { size_t curr_prefix_len = cp - curr_installdir; @@ -264,9 +267,13 @@ compute_curr_prefix (const char *orig_installprefix, curr_prefix = (char *) xmalloc (curr_prefix_len + 1); #ifdef NO_XMALLOC if (curr_prefix == NULL) - return NULL; + { + free((char*)curr_installdir); + return NULL; + } #endif memcpy (curr_prefix, curr_installdir, curr_prefix_len); + free((char*)curr_installdir); curr_prefix[curr_prefix_len] = '\0'; return curr_prefix;