Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

When initialize a message with an invalid array, the first invalid key of the given array will be changed to an exception #52

Open
bryceliu opened this issue Jan 20, 2015 · 0 comments

Comments

@bryceliu
Copy link

When initialize a message with an invalid array, the first invalid key of the given array will be changed to an exception. Segmentation fault also.

Message definition

message Person
{
    required bytes name = 1;
    required uint32 age = 2;
}

PHP test code

require 'person.proto.php';
$info = [
    'fake_name' => 'bryce',
    'age' => 18
];
var_dump($info);
$person = new Person();
try {
    $person->setFrom($info);
} catch (Exception $e) {
}
var_dump($info);

PHP output

array(2) {
  'fake_name' =>
  string(5) "bryce"
  'age' =>
  int(18)
}
array(2) {
  'fake_name' =>
  class InvalidArgumentException#4 (8) {
    protected $message =>
    string(23) "fake_name does not find"
    private $string =>
    string(0) ""
    protected $code =>
    int(0)
    protected $file =>
    string(32) "/home/bryceliu/c/person/test.php"
    protected $line =>
    int(10)
    private $trace =>
    array(1) {
      [0] =>
      array(6) {
        ...
      }
    }
    private $previous =>
    NULL
    public $xdebug_message =>
    string(279) "
InvalidArgumentException: fake_name does not find in /home/bryceliu/c/person/test.php on line 10

Call Stack:
    0.0002     223440   1. {main}() /home/bryceliu/c/person/test.php:0
    0.0013     252648   2. ProtocolBuffersMessage->setFrom() /home/bryceliu/c/person/test.php:10
"
  }
  'age' =>
  int(18)
}
Segmentation fault
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant