From 08a81751cb2f8d905c78955623c4b0de5d4046fd Mon Sep 17 00:00:00 2001 From: David Cole Date: Wed, 29 Sep 2021 01:06:45 +1300 Subject: [PATCH] Fixed `ZendString` missing one character --- CHANGELOG.md | 2 ++ src/php/types/string.rs | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 06367a4385..6429752a66 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,8 +2,10 @@ - `PhpException` no longer requires a lifetime [#80]. - Added `PhpException` and `PhpResult` to prelude [#80]. +- Fixed `ZendString` missing last character [#82]. [#80]: https://github.com/davidcole1340/ext-php-rs/pull/80 +[#82]: https://github.com/davidcole1340/ext-php-rs/pull/82 ## Version 0.5.0 diff --git a/src/php/types/string.rs b/src/php/types/string.rs index aae92f4392..8c5e7f75c7 100644 --- a/src/php/types/string.rs +++ b/src/php/types/string.rs @@ -54,7 +54,7 @@ impl ZendStr { pub fn as_c_str(&self) -> &CStr { // SAFETY: Zend strings store their readable length in a fat pointer. unsafe { - let slice = slice::from_raw_parts(self.val.as_ptr() as *const u8, self.len()); + let slice = slice::from_raw_parts(self.val.as_ptr() as *const u8, self.len() + 1); CStr::from_bytes_with_nul_unchecked(slice) } }