diff options
author | David Vossel <dvossel@digium.com> | 2009-11-06 15:42:46 +0000 |
---|---|---|
committer | David Vossel <dvossel@digium.com> | 2009-11-06 15:42:46 +0000 |
commit | 71a29c3ffcea840bdf24b01833b54ed6b2040adc (patch) | |
tree | b74a44d7a15ac412ebb04dd6032fe1255f74ab6d /main/astfd.c | |
parent | ea960fc29c9af8e4a646199520a5b4c627e55f4e (diff) |
Merged revisions 228338 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4
........
r228338 | dvossel | 2009-11-06 09:41:41 -0600 (Fri, 06 Nov 2009) | 5 lines
fixes crash in astfd.c
(closes issue #15981)
Reported by: slavon
........
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@228339 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'main/astfd.c')
-rw-r--r-- | main/astfd.c | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/main/astfd.c b/main/astfd.c index 6a9f70e42..90ded390f 100644 --- a/main/astfd.c +++ b/main/astfd.c @@ -130,15 +130,16 @@ int __ast_fdleak_pipe(int *fds, const char *file, int line, const char *func) #undef socket int __ast_fdleak_socket(int domain, int type, int protocol, const char *file, int line, const char *func) { - char sdomain[20], stype[20], *sproto; + char sdomain[20], stype[20], *sproto = NULL; struct protoent *pe; int res = socket(domain, type, protocol); if (res < 0 || res > 1023) { return res; } - pe = getprotobynumber(protocol); - sproto = pe->p_name; + if ((pe = getprotobynumber(protocol))) { + sproto = pe->p_name; + } if (domain == PF_UNIX) { ast_copy_string(sdomain, "PF_UNIX", sizeof(sdomain)); @@ -162,7 +163,11 @@ int __ast_fdleak_socket(int domain, int type, int protocol, const char *file, in snprintf(stype, sizeof(stype), "%d", type); } - STORE_COMMON(res, "socket", "%s,%s,\"%s\"", sdomain, stype, sproto); + if (sproto) { + STORE_COMMON(res, "socket", "%s,%s,\"%s\"", sdomain, stype, sproto); + } else { + STORE_COMMON(res, "socket", "%s,%s,\"%d\"", sdomain, stype, protocol); + } return res; } |