> Sylvain Beucler <[EMAIL PROTECTED]> writes:
>
> > Attached is a small patch to fix a couple non-fred memory blocks. They
> > are not a big deal, but they do produce noise when analyzing programs
> > with memory checkers such as Valgrind.
>
> I do not see the attachment.
>
> > Another thing:, the relocatable module documentation recommends using:
> > bindtextdomain (PACKAGE, relocate (LOCALEDIR));
> > however, the result of relocate may be LOCALEDIR itself (no
> > relocation) or a newly allocated string.
> [...]
> > Maybe it would be cleaner to always return a newly allocated string?
>
> This does seem reasonable to me, but I will wait to hear Bruno's
> opinion before I do anything.
> --
> Ben Pfaff
> http://benpfaff.org
Hi,
(I'm not subscribed to the list, please keep me in Cc)
Sorry, I do attach the patch now :)
--
Sylvain
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;