Skip to content

Commit a404df8

Browse files
Fixed ZendString missing one character (#82)
1 parent aed061d commit a404df8

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,10 @@
22

33
- `PhpException` no longer requires a lifetime [#80].
44
- Added `PhpException` and `PhpResult` to prelude [#80].
5+
- Fixed `ZendString` missing last character [#82].
56

67
[#80]: https://github.com/davidcole1340/ext-php-rs/pull/80
8+
[#82]: https://github.com/davidcole1340/ext-php-rs/pull/82
79

810
## Version 0.5.0
911

src/php/types/string.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ impl ZendStr {
5454
pub fn as_c_str(&self) -> &CStr {
5555
// SAFETY: Zend strings store their readable length in a fat pointer.
5656
unsafe {
57-
let slice = slice::from_raw_parts(self.val.as_ptr() as *const u8, self.len());
57+
let slice = slice::from_raw_parts(self.val.as_ptr() as *const u8, self.len() + 1);
5858
CStr::from_bytes_with_nul_unchecked(slice)
5959
}
6060
}

0 commit comments

Comments
 (0)