Skip to content

Commit ca08b5a

Browse files
authored
fix(agent): nr_execute_handle_autoload needs null check for txn (#1086)
`nr_execute_handle_autoload` wasn't accounting for the possibility of txn being null which would lead to unpredictable behavior when accessing it [here](https://github.com/newrelic/newrelic-php-agent/blob/dev/agent/php_execute.c#L894), and we would cause corruption when we [set this value](https://github.com/newrelic/newrelic-php-agent/blob/dev/agent/php_execute.c#L907). txn can be null in cases where nr_php_txn_end has been called. such as: https://github.com/newrelic/newrelic-php-agent/blob/dev/agent/fw_laravel_queue.c#L355-L356
1 parent ae34b4f commit ca08b5a

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

agent/php_execute.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -891,6 +891,14 @@ static void nr_execute_handle_autoload(const char* filename,
891891
return;
892892
}
893893

894+
/*
895+
* There is a possibility of the txn being NULL if nr_php_end_txn has been called.
896+
* Verify txn is not null before dereferencing and continuing on.
897+
*/
898+
if (NULL == NRPRG(txn)) {
899+
return;
900+
}
901+
894902
if (NRPRG(txn)->composer_info.autoload_detected) {
895903
// autoload already handled
896904
return;

0 commit comments

Comments
 (0)