summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
Diffstat (limited to 'ext')
-rw-r--r--ext/shmop/shmop.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/ext/shmop/shmop.c b/ext/shmop/shmop.c
index 0c8c0c2cc5..7e4fa3df0e 100644
--- a/ext/shmop/shmop.c
+++ b/ext/shmop/shmop.c
@@ -242,8 +242,9 @@ PHP_FUNCTION(shmop_read)
startaddr = shmop->addr + (*start)->value.lval;
bytes = (*count)->value.lval ? (*count)->value.lval : shmop->size-(*start)->value.lval;
- return_string = emalloc(bytes);
+ return_string = emalloc(bytes+1);
memcpy(return_string, startaddr, bytes);
+ return_string[bytes] = 0;
RETURN_STRINGL(return_string, bytes, 0);
}