RDKB-60813 : jst crash fix#8
Conversation
Reason for change: jst crash fix Test Procedure: As per ticket Risks: Medium Priority: P0 Signed-off-by: Harnish_Patel@comcast.com Change-Id: I109a372871f9fb28c763d5923e334c440c3c10dd (cherry picked from commit 3a5406eb14d164ee2ea14ed1ab70a76019e00ec7)
There was a problem hiding this comment.
Pull request overview
Fixes a crash in JST POST handling by adjusting memory ownership for multipart/form-data requests in ccsp_post_module_open, avoiding freeing the POST buffer when it is retained for later retrieval.
Changes:
- Conditionally free
content_dataafter multipart parsing to avoid freeing memory thatpost_datapoints to (prevents double-free/use-after-free crash).
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| if (post_data == NULL || post_data != content_data) { | ||
| free(content_data); | ||
| } |
There was a problem hiding this comment.
The new if block uses tab indentation and a brace/indent style that doesn’t match the surrounding file (which appears to use consistent 2-space indentation). Please reformat these lines to match local style for readability and diff hygiene.
| if (post_data == NULL || post_data != content_data) { | |
| free(content_data); | |
| } | |
| if (post_data == NULL || post_data != content_data) { | |
| free(content_data); | |
| } |
| if (post_data == NULL || post_data != content_data) { | ||
| free(content_data); | ||
| } |
There was a problem hiding this comment.
if (post_data == NULL || post_data != content_data) is logically equivalent to post_data != content_data here because content_data is non-NULL on this path. Simplifying the condition would improve readability and reduce redundant checks.
| if (post_data == NULL || post_data != content_data) { | |
| free(content_data); | |
| } | |
| if (post_data != content_data) { | |
| free(content_data); | |
| } |
Reason for change: jst crash fix
Test Procedure: As per ticket
Risks: Medium
Priority: P0
Signed-off-by: Harnish_Patel@comcast.com
Change-Id: I109a372871f9fb28c763d5923e334c440c3c10dd (cherry picked from commit 3a5406eb14d164ee2ea14ed1ab70a76019e00ec7)