summaryrefslogtreecommitdiff
path: root/source3
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2006-03-29 22:41:24 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 11:15:47 -0500
commitb84d06dae754ef2f637bc6549c63a5062afbbab6 (patch)
tree5b44ff687c7cbe25007a277b8c53361f7759e67f /source3
parent81d4f40bbe202e5dae3d4d1070b02edf16a9f62e (diff)
downloadsamba-b84d06dae754ef2f637bc6549c63a5062afbbab6.tar.gz
samba-b84d06dae754ef2f637bc6549c63a5062afbbab6.tar.bz2
samba-b84d06dae754ef2f637bc6549c63a5062afbbab6.zip
r14764: Fix possible null pointer deref. Coverity #253.
Jeremy. (This used to be commit 7a18f38947385b8a5fb27a42610320003689e9e1)
Diffstat (limited to 'source3')
-rw-r--r--source3/lib/util_pw.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/source3/lib/util_pw.c b/source3/lib/util_pw.c
index e1bea1a646..754899f420 100644
--- a/source3/lib/util_pw.c
+++ b/source3/lib/util_pw.c
@@ -25,6 +25,9 @@
struct passwd *tcopy_passwd(TALLOC_CTX *mem_ctx, const struct passwd *from)
{
struct passwd *ret = TALLOC_P(mem_ctx, struct passwd);
+ if (!ret) {
+ return NULL;
+ }
ret->pw_name = talloc_strdup(ret, from->pw_name);
ret->pw_passwd = talloc_strdup(ret, from->pw_passwd);
ret->pw_uid = from->pw_uid;
@@ -99,8 +102,7 @@ struct passwd *getpwnam_alloc(TALLOC_CTX *mem_ctx, const char *name)
}
pwnam_cache[i] = tcopy_passwd(pwnam_cache, temp);
-
- if (mem_ctx != NULL) {
+ if (pwnam_cache[i]!= NULL && mem_ctx != NULL) {
return talloc_reference(mem_ctx, pwnam_cache[i]);
}