[asterisk-commits] russell: branch 1.2 r59277 - /branches/1.2/apps/app_directory.c

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Tue Mar 27 16:19:42 MST 2007


Author: russell
Date: Tue Mar 27 18:19:41 2007
New Revision: 59277

URL: http://svn.digium.com/view/asterisk?view=rev&rev=59277
Log:
Fix the check of the return value from mmap().  Thanks to Corydon for catching
this one.

Modified:
    branches/1.2/apps/app_directory.c

Modified: branches/1.2/apps/app_directory.c
URL: http://svn.digium.com/view/asterisk/branches/1.2/apps/app_directory.c?view=diff&rev=59277&r1=59276&r2=59277
==============================================================================
--- branches/1.2/apps/app_directory.c (original)
+++ branches/1.2/apps/app_directory.c Tue Mar 27 18:19:41 2007
@@ -94,7 +94,7 @@
 	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 @@
 				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 @@
 		} 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);



More information about the asterisk-commits mailing list