apache
File descriptor leak ("dbg") with DEBUG_CGI.
Return statement occurs before freeing the "dbg" pointer, so we have a leak.
Bug fixed by commit 4945115b2e7
Type | FileDescriptorLeak |
Config | DEBUG_CGI (1st degree) |
Fix-in | code |
Location | modules/generators/ |
#include <stdio.h> #include <stdlib.h> void run_cgi_child() { #ifdef DEBUG_CGI #ifdef OS2 FILE *dbg = fopen("con", "w"); #else FILE *dbg = fopen("/dev/tty", "w"); #endif #endif #ifdef DEBUG_CGI fprintf(dbg, "Environment\n"); #endif if(rand() % 2) return; // ERROR: dbg is leaked #ifdef DEBUG_CGI fclose(dbg); #endif return; } void cgi_handler() { run_cgi_child(); } int main(void) { cgi_handler(); return 0; }
. call modules/generators/mod_cgi.c:743:cgi_handler() . 826: run_cgi_child() .. call modules/generators/mod_cgi.c:371:run_cgi_child() .. // if DEBUG_CGI and OS2 are enabled .. 395: FILE *dbg = fopen("con", "w"); .. ERROR 467: return APR_EBADF;