summaryrefslogtreecommitdiff
path: root/source3/lib
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2017-10-03 10:37:55 -0700
committerKarolin Seeger <kseeger@samba.org>2017-10-25 08:43:04 +0200
commit6b1971fe39cc91ae450d28238fe3f81758d0e6fd (patch)
tree4a02331b6ba1d6708e94793a5bbbe4a4bf27c722 /source3/lib
parente507bcdd6844075f4ab996192d2d19df77c3cbbf (diff)
downloadsamba-6b1971fe39cc91ae450d28238fe3f81758d0e6fd.tar.gz
s3: VFS: Ensure sys_getwd() doesn't leak memory on error on really old systems.
BUG: https://bugzilla.samba.org/show_bug.cgi?id=13069 Signed-off-by: Jeremy Allison <jra@samba.org> Reviewed-by: Ralph Boehme <slow@samba.org> (cherry picked from commit fb9ce0685e5d46e3d7abf5fac07b4f626339a413)
Diffstat (limited to 'source3/lib')
-rw-r--r--source3/lib/system.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/source3/lib/system.c b/source3/lib/system.c
index 99462b631c7..01c934277ac 100644
--- a/source3/lib/system.c
+++ b/source3/lib/system.c
@@ -605,11 +605,16 @@ char *sys_getwd(void)
}
return wd;
#else
+ char *wd = NULL;
char *s = SMB_MALLOC_ARRAY(char, PATH_MAX);
if (s == NULL) {
return NULL;
}
- return getwd(s);
+ wd = getwd(s);
+ if (wd == NULL) {
+ SAFE_FREE(s);
+ }
+ return wd;
#endif
}