Skip to content

Commit

Permalink
Merge pull request #20 from m6w6/fix-19
Browse files Browse the repository at this point in the history
fix #19
  • Loading branch information
rlerdorf committed Apr 21, 2022
2 parents ea13067 + 91ace82 commit 6c71f71
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 5 deletions.
2 changes: 1 addition & 1 deletion package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ Requirements: ext/hash (now a part of PHP core)
<license uri="http://www.opensource.org/licenses/bsd-license.php">BSD</license>
<notes>
<![CDATA[
* WIP
* Fix gh issue #19: Segfault in checkOAuthRequest()
]]>
</notes>
<contents>
Expand Down
8 changes: 4 additions & 4 deletions provider.c
Original file line number Diff line number Diff line change
Expand Up @@ -753,7 +753,10 @@ SOP_METHOD(checkOAuthRequest)
long cb_res;

retval = oauth_provider_call_cb(INTERNAL_FUNCTION_PARAM_PASSTHRU, OAUTH_PROVIDER_CONSUMER_CB);
if (retval) {
if (EG(exception)) {
/* pass exceptions */
break;
} else if (retval) {
convert_to_long(retval);
cb_res = Z_LVAL_P(retval);
zval_ptr_dtor(retval);
Expand All @@ -762,9 +765,6 @@ SOP_METHOD(checkOAuthRequest)
soo_handle_error(NULL, cb_res, "Invalid consumer key", NULL, additional_info);
break;
}
} else if (EG(exception)) {
/* pass exceptions */
break;
}

if (is_token_required) {
Expand Down
30 changes: 30 additions & 0 deletions tests/issue019.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
--TEST--
GH issue #19 - Segfault in checkOAuthRequest()
--FILE--
<?php
require 'oauth.inc';
$ret = "0";

try {
$provider = new OAuthProvider(creationParams());
$provider->consumerHandler(function() use (&$ret) {
foo();
});
$provider->timestampNonceHandler(function() {
bar();
});
$provider->tokenHandler(function() {
global $ret;
baz();
});

$provider->checkOAuthRequest("http://localhost/request_token.php", OAUTH_HTTP_METHOD_GET);

} catch (OAuthException $E) {
echo OAuthProvider::reportProblem($E);
} catch (Throwable $T) {
echo "Caught ", get_class($T), "\n";
}
?>
--EXPECT--
Caught Error

0 comments on commit 6c71f71

Please sign in to comment.