-
Notifications
You must be signed in to change notification settings - Fork 7.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
httpd_sess_free_ctx in httpd_req_cleanup uses wrong context pointer (IDFGH-8842) #10265
Comments
Hello @sforconi, |
Hi, In my opinion, the |
@sforconi Got it. Was able to reproduce it. Will fix it. Thanks! |
Added example which fails without the fix Closes #10265
Added example which fails without the fix Closes #10265
Added example which fails without the fix Closes espressif/esp-idf#10265
Answers checklist.
IDF version.
v4.4.x
Operating System used.
Linux
How did you build your project?
VS Code IDE
If you are using Windows, please specify command line type.
No response
Development Kit.
ESP32-S3-DevKitC
Power Supply used.
USB
What is the expected behavior?
The code should not crash when a previously allocated session context is reset to NULL in another uri handler.
As pointed in the documentation: "By default, if you change the sess_ctx in some URI handler, the http server will internally free the earlier context (if non NULL), after the URI handler returns."
What is the actual behavior?
The firmware crashes.
Steps to reproduce.
req->sess_ctx = malloc(...);
req->sess_ctx = NULL
Debug Logs.
More Information.
In function
httpd_req_cleanup(httpd_req_t *r)
, in filehttpd_parse.c
, the functionhttpd_sess_free_ctx(void **ctx, httpd_free_ctx_fn_t free_fn)
is invoked as:httpd_sess_free_ctx(ra->sd->ctx, ra->sd->free_ctx);
instead it should be:
httpd_sess_free_ctx(&ra->sd->ctx, ra->sd->free_ctx);
The text was updated successfully, but these errors were encountered: