Fix critical bugs in audit record processing: NULL checks, memory leaks, and statistics corruption #34425
+36
−27
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Code review identified critical bugs in the audit self-save functionality that could cause crashes, memory leaks, and incorrect statistics on failure paths.
Changes
Fix statistics corruption: Wrap all statistics/metrics updates in success check -
nInsert,nInsertSuccess,nBatchInsert, and monitoring counters were being incremented even when operations failedAdd NULL pointer guards:
tjsonGetArrayItem()result before use (can return NULL for invalid arrays)req.dataafter deserialization (can be NULL for empty strings)Fix memory leaks: Replace early returns with
TAOS_CHECK_GOTOto ensuretFreeSVAuditRecordReq()cleanup always runsCode quality: Remove duplicate "failed" in error message, add braces for multi-line if statements
Files Changed
source/dnode/vnode/src/vnd/vnodeSvr.c- Error handling invnodeProcessAuditRecordReqandvnodeSaveOneAuditRecord💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.