MFB51: Fixed bug #36148 (unpack("H*hex", $data) is adding an extra

character to the end of the string).
This commit is contained in:
Ilia Alshanetsky 2006-01-26 15:48:15 +00:00
parent 98ca921fb2
commit b031ac3fe4
2 changed files with 32 additions and 1 deletions

View file

@ -692,7 +692,9 @@ PHP_FUNCTION(unpack)
len = size * 2;
}
if (argb > 0) {
len -= argb % 2;
}
buf = emalloc(len + 1);

View file

@ -0,0 +1,29 @@
--TEST--
Bug #36148 (unpack("H*hex", $data) is adding an extra character to the end of the string)
--FILE--
<?php
$values = array("a", "aa", "aaa", "aaaa");
foreach ($values as $value) {
$a = pack("H*", $value);
$b = unpack("H*", $a);
echo $value.": ";
var_dump($b);
}
?>
--EXPECT--
a: array(1) {
[1]=>
string(2) "a0"
}
aa: array(1) {
[1]=>
string(2) "aa"
}
aaa: array(1) {
[1]=>
string(4) "aaa0"
}
aaaa: array(1) {
[1]=>
string(4) "aaaa"
}