codemem: check ftruncate() return value
authorDavid Schleef <ds@schleef.org>
Mon, 25 Apr 2011 22:09:35 +0000 (15:09 -0700)
committerDavid Schleef <ds@schleef.org>
Mon, 25 Apr 2011 22:09:35 +0000 (15:09 -0700)
orc/orccodemem.c

index 96fc3a4..1760ec4 100644 (file)
@@ -210,6 +210,11 @@ orc_code_region_allocate_codemem_dual_map (OrcCodeRegion *region,
   free (filename);
 
   n = ftruncate (fd, SIZE);
+  if (n < 0) {
+    ORC_WARNING("failed to expand file to size");
+    close (fd);
+    return FALSE;
+  }
 
   region->exec_ptr = mmap (NULL, SIZE, PROT_READ|PROT_EXEC,
       MAP_SHARED, fd, 0);