From: Tilghman Lesher Date: Mon, 20 Nov 2006 19:59:07 +0000 (+0000) Subject: Failing to trap -1 error from mmap causes segfault (Issue 8385) X-Git-Tag: 1.2.14~41 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0e783db6909d20f1d20b1a106d559497555a17c9;p=thirdparty%2Fasterisk.git Failing to trap -1 error from mmap causes segfault (Issue 8385) git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.2@47862 65c4cc65-6c06-0410-ace0-fbb531ad65f3 --- diff --git a/apps/app_voicemail.c b/apps/app_voicemail.c index 34f8303eb6..e76669db7d 100644 --- a/apps/app_voicemail.c +++ b/apps/app_voicemail.c @@ -935,8 +935,13 @@ static int retrieve_file(char *dir, int msgnum) fd = -1; continue; } - if (fd > -1) - fdm = mmap(NULL, fdlen, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0); + if (fd > -1) { + if ((fdm = mmap(NULL, fdlen, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0)) == -1) { + ast_log(LOG_WARNING, "Could not mmap the output file: %s (%d)\n", strerror(errno), errno); + SQLFreeHandle(SQL_HANDLE_STMT, stmt); + goto yuck; + } + } } if (fdm) { memset(fdm, 0, fdlen);