Skip to content

Commit 587d28e

Browse files
committed
Protect against invalid state in getSubUser()
1 parent 2ea936c commit 587d28e

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

src/SendGrid/Api.php

+9-2
Original file line numberDiff line numberDiff line change
@@ -95,11 +95,18 @@ public function getSubUser ($username) {
9595
return $elm->username == $username;
9696
});
9797

98-
if (empty($match)) {
98+
if (empty($match) || !isset($match[0]) || empty($match[0])) {
9999
throw new InvalidArgumentException("No subuser '$username' found.");
100100
}
101101

102-
extract(get_object_vars($match[0]));
102+
$vars = get_object_vars($match[0]);
103+
if (!$vars) {
104+
throw new InvalidArgumentException("Unexpected result when retrieving '$username'.");
105+
}
106+
107+
$email = $first_name = $last_name = $address = $city = $state = $zip = $country = $phone = $website = null;
108+
extract($vars);
109+
103110
return new SubUser($username, null, $email, null, $first_name, $last_name,
104111
$address, $city, $state, $zip, $country, $phone, $website,
105112
$this);

0 commit comments

Comments
 (0)