]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
Fix the check of the return value from mmap(). Thanks to Corydon for catching
authorRussell Bryant <russell@russellbryant.com>
Tue, 27 Mar 2007 23:19:41 +0000 (23:19 +0000)
committerRussell Bryant <russell@russellbryant.com>
Tue, 27 Mar 2007 23:19:41 +0000 (23:19 +0000)
this one.

git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.2@59277 65c4cc65-6c06-0410-ace0-fbb531ad65f3

apps/app_directory.c

index 9caefc0304b2066b882b112e47a4eedbd6cc99e5..2b1d4e9677f02805f284417b8d2bd8b70aea7299 100644 (file)
@@ -94,7 +94,7 @@ static void retrieve_file(char *dir)
        int res;
        int fd=-1;
        size_t fdlen = 0;
-       void *fdm=NULL;
+       void *fdm = MAP_FAILED;
        SQLHSTMT stmt;
        char sql[256];
        char fmt[80]="";
@@ -161,7 +161,7 @@ static void retrieve_file(char *dir)
                                if (fd > -1)
                                        fdm = mmap(NULL, fdlen, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
                        }
-                       if (fdm) {
+                       if (fdm != MAP_FAILED) {
                                memset(fdm, 0, fdlen);
                                res = SQLGetData(stmt, x + 1, SQL_BINARY, fdm, fdlen, &colsize);
                                if ((res != SQL_SUCCESS) && (res != SQL_SUCCESS_WITH_INFO)) {
@@ -174,7 +174,7 @@ static void retrieve_file(char *dir)
                } while (0);
        } else
                ast_log(LOG_WARNING, "Failed to obtain database object for '%s'!\n", odbc_database);
-       if (fdm)
+       if (fdm != MAP_FAILED)
                munmap(fdm, fdlen);
        if (fd > -1)
                close(fd);