Skip to content

Commit

Permalink
PHP: Fix a possible file-pointer leak.
Browse files Browse the repository at this point in the history
In nxt_php_execute() it is possible we could bail out before cleaning up
the FILE * representing the PHP script to execute.

At this point we only need to call fclose(3) on it.

We could have possibly moved the opening of this file to later in the
function, but it is probably good to bail out as early as possible if we
can't open it.

This was found by Coverity.

Fixes: bebc03c ("PHP: Implement better error handling.")
Signed-off-by: Andrew Clayton <a.clayton@nginx.com>
  • Loading branch information
ac000 committed Nov 15, 2023
1 parent 27c787f commit 919cae7
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/nxt_php_sapi.c
Original file line number Diff line number Diff line change
Expand Up @@ -1225,6 +1225,8 @@ nxt_php_execute(nxt_php_run_ctx_t *ctx, nxt_unit_request_t *r)
nxt_unit_req_debug(ctx->req, "php_request_startup() failed");

nxt_unit_request_done(ctx->req, NXT_UNIT_ERROR);
fclose(fp);

return;
}

Expand Down

0 comments on commit 919cae7

Please sign in to comment.