summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authormidipix <writeonce@midipix.org>2016-10-26 21:04:18 -0400
committermidipix <writeonce@midipix.org>2016-10-26 22:10:30 -0400
commit2c6143fdb0cc12997a2a09268f4797931f73947d (patch)
treef3c4a1c67d043e5057df4d953e66dd2918b0c65e
parentbb5e477926b1aa1732c862b34e3b515406b18bc5 (diff)
downloadapimagic-2c6143fdb0cc12997a2a09268f4797931f73947d.tar.bz2
apimagic-2c6143fdb0cc12997a2a09268f4797931f73947d.tar.xz
amgc_map_input(): improved error trace support.
-rw-r--r--src/logic/amgc_map_input.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/logic/amgc_map_input.c b/src/logic/amgc_map_input.c
index b4e07ea..c0d4a2b 100644
--- a/src/logic/amgc_map_input.c
+++ b/src/logic/amgc_map_input.c
@@ -35,9 +35,16 @@ int amgc_map_input(
if ((ret = fstat(fd,&st) < 0) && fnew)
close(fd);
+ else if ((st.st_size == 0) && fnew)
+ close(fd);
+
if (ret < 0)
return AMGC_SYSTEM_ERROR(dctx);
+ else if (st.st_size == 0)
+ return AMGC_CUSTOM_ERROR(
+ dctx,AMGC_ERR_SOURCE_SIZE_ZERO);
+
map->size = st.st_size;
map->addr = mmap(0,map->size,prot,MAP_PRIVATE,fd,0);