[PATCH 21/28] Handle errors when getting SC_PAGESIZE

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Signed-off-by: Jan Friesse <jfriesse@xxxxxxxxxx>
---
 lib/cpg.c |    7 ++++++-
 1 files changed, 6 insertions(+), 1 deletions(-)

diff --git a/lib/cpg.c b/lib/cpg.c
index 8408466..a7dad33 100644
--- a/lib/cpg.c
+++ b/lib/cpg.c
@@ -736,6 +736,7 @@ memory_map (char *path, const char *file, void **buf, size_t bytes)
 	int32_t i;
 	size_t written;
 	size_t page_size; 
+	long int sysconf_page_size;
 
 	snprintf (path, PATH_MAX, "/dev/shm/%s", file);
 
@@ -752,7 +753,11 @@ memory_map (char *path, const char *file, void **buf, size_t bytes)
 	if (res == -1) {
 		goto error_close_unlink;
 	}
-	page_size = (size_t)sysconf(_SC_PAGESIZE);
+	sysconf_page_size = sysconf(_SC_PAGESIZE);
+	if (sysconf_page_size <= 0) {
+		goto error_close_unlink;
+	}
+	page_size = sysconf_page_size;
 	buffer = malloc (page_size);
 	if (buffer == NULL) {
 		goto error_close_unlink;
-- 
1.7.1

_______________________________________________
discuss mailing list
discuss@xxxxxxxxxxxx
http://lists.corosync.org/mailman/listinfo/discuss




[Index of Archives]     [Linux Clusters]     [Corosync Project]     [Linux USB Devel]     [Linux Audio Users]     [Photo]     [Yosemite News]    [Yosemite Photos]    [Linux Kernel]     [Linux SCSI]     [X.Org]

  Powered by Linux