diff options
author | Jeremy Allison <jra@samba.org> | 2006-03-29 22:41:24 +0000 |
---|---|---|
committer | Jeremy Allison <jra@samba.org> | 2006-03-29 22:41:24 +0000 |
commit | 83a148b45b2d22dbaeeda719f7fa09dc493eb950 (patch) | |
tree | f17b7d1db5b35b50150ca1eb6671aa454b76e28d /source/lib/util_pw.c | |
parent | e16139f715777e1fc909b65ce1a6267dee5bbeb0 (diff) | |
download | samba-83a148b45b2d22dbaeeda719f7fa09dc493eb950.tar.gz samba-83a148b45b2d22dbaeeda719f7fa09dc493eb950.tar.xz samba-83a148b45b2d22dbaeeda719f7fa09dc493eb950.zip |
r14764: Fix possible null pointer deref. Coverity #253.
Jeremy.
Diffstat (limited to 'source/lib/util_pw.c')
-rw-r--r-- | source/lib/util_pw.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/source/lib/util_pw.c b/source/lib/util_pw.c index e1bea1a6465..754899f420e 100644 --- a/source/lib/util_pw.c +++ b/source/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]); } |