Skip to content

Commit

Permalink
Fixes crash #363
Browse files Browse the repository at this point in the history
  • Loading branch information
ikkentim committed Dec 7, 2020
1 parent e58afb5 commit b981515
Showing 1 changed file with 8 additions and 11 deletions.
19 changes: 8 additions & 11 deletions src/SampSharp/includes/sampgdk/sampgdk.c
Original file line number Diff line number Diff line change
Expand Up @@ -1899,13 +1899,6 @@ bool sampgdk_callback_invoke(AMX *amx,

assert(amx != NULL);

callback = _sampgdk_callback_find(name);
callback_filter = _sampgdk_callback_find(":OnPublicCall");
callback_filter2 = _sampgdk_callback_find(":OnPublicCall2");

assert(callback_filter != NULL);
assert(callback_filter2 != NULL);

if (paramcount > _SAMPGDK_CALLBACK_MAX_ARGS) {
sampgdk_log_error("Too many callback arguments (at most %d allowed)",
_SAMPGDK_CALLBACK_MAX_ARGS);
Expand All @@ -1922,20 +1915,22 @@ bool sampgdk_callback_invoke(AMX *amx,
void *func;
bool do_call = true;
bool stop = false;


callback_filter = _sampgdk_callback_find(":OnPublicCall");
assert(callback_filter != NULL);
func = sampgdk_plugin_get_symbol(plugin, callback_filter->func_name);
//printf("pre %s %d %d\n", name, callback_filter->func_name, callback_filter2->func_name);
if (func != NULL) {
do_call = ((_sampgdk_callback_filter)func)(amx, name, params, retval);
}
//printf("post %s %d %d\n", name, callback_filter->func_name, callback_filter2->func_name);

/* callback_filter2 is similar to callback_filter except it can stop
* propagation of public call to other plugins. It was added for backwards
* compatibility.
*
* callback_filter2's return value overrides that of callback_filter.
*/
callback_filter2 = _sampgdk_callback_find(":OnPublicCall2");
assert(callback_filter2 != NULL);
func = sampgdk_plugin_get_symbol(plugin, callback_filter2->func_name);
if (func != NULL) {
do_call = !((_sampgdk_callback_filter2)func)(amx,
Expand All @@ -1948,10 +1943,12 @@ bool sampgdk_callback_invoke(AMX *amx,
if (stop) {
return false;
}

callback = _sampgdk_callback_find(name);
if (!do_call || callback == NULL || callback->handler == NULL) {
continue;
}

func = sampgdk_plugin_get_symbol(plugin, callback->func_name);
if (func != NULL
&& !((sampgdk_callback)callback->handler)(amx, func, retval)) {
Expand Down

0 comments on commit b981515

Please sign in to comment.