[PATCH] Tiny memory leak in lib/version.c
Corinna Vinschen
corinna at vinschen.de
Sat Jan 19 14:14:45 GMT 2008
Hi,
while implementing the extra_info version stuff, it occured to me that
samba_version_string() potentially allocates memory which is unused but
never free'd.
If SAMBA_VERSION_VENDOR_PATCH is defined, a second call to asprintf
takes place. The result is stored in tmp_version. Afterwards,
samba_version is set to tmp_version without free'ing samba_version
first. Looks like a simple free(samba_version) is missing. Patch
against 3.2-test below.
Ok, this only happens once over the lifetime of the application, so it's
no big deal, but I though it doesn't hurt to mention it.
Corinna
* lib/version.c (samba_version_string): Free samba_version
before setting to tmp_version.
diff --git a/source/lib/version.c b/source/lib/version.c
index 204c204..cbb70ae 100644
--- a/source/lib/version.c
+++ b/source/lib/version.c
@@ -51,6 +51,7 @@ const char *samba_version_string(void)
*/
assert(res != -1);
+ free(samba_version);
samba_version = tmp_version;
#endif
More information about the samba-technical
mailing list