Fixed ZendString missing one character (#82)

This commit is contained in:
David 2021-09-29 01:07:30 +13:00 committed by GitHub
parent aed061d7be
commit a404df8fed
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 1 deletions

View File

@ -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

View File

@ -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)
}
}