Repository navigation
Conversation
Three export paths allocated copy buffers with new char[] but held them in QScopedPointer<char>, whose destructor calls scalar delete — an alloc-dealloc mismatch (undefined behavior). Under the UT script's AddressSanitizer run this aborted the whole test binary at UT_DLDBusHandler.exportLog_home_file_copy_succeeds, so the main suite contributed no results and reported coverage collapsed to the plugin binary's numbers. Switch to QScopedArrayPointer<char> so the buffers are freed with delete[]: - application/dbusproxy/dldbushandler.cpp:356 (home-path file copy) - logViewerService/logviewerservice.cpp:1256 (exportLog copy loop) - logViewerService/logviewerservice.cpp:1430 (large buffered export) Verified: the crashing test plus the LogViewerService export tests (8 cases) now pass with plain ASAN_OPTIONS=detect_leaks=0.
|
Sorry @pengfeixx, you've used your own review budget of 250,000 diff characters for the last 7 days. You can request another review in 1 hour and 13 minutes by commenting |
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: pengfeixx The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
Reviewer's guide (collapsed on small PRs)Reviewer's GuideFixes an AddressSanitizer alloc/dealloc mismatch by changing three 1 MiB export buffers from QScopedPointer to QScopedArrayPointer, ensuring allocations made with new[] are released with delete[] while leaving export behavior unchanged. File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
deepin pr auto review🤖 AI 代码审查报告📊 总体评价
🔍 详细分析1. 语法逻辑 ✅评价: 语法正确,逻辑清晰 ✅ 通过 潜在问题: 建议: [] 2. 代码质量 ✅评价: 代码结构清晰,注释完整 ✅ 通过 潜在问题: 建议: [] 3. 代码性能 ✅评价: 性能良好,资源使用合理 ✅ 通过 潜在问题: 建议: [] 4. 代码安全 🔒评价: 存在0个安全漏洞 ✅ 通过
安全漏洞详情: 建议: [] 💡 改进建议代码示例// 修复方式已正确,无需额外修改。以下是正确的用法示例:
#include <QScopedArrayPointer>
// 正确:QScopedArrayPointer 使用 delete[] 释放 new[] 分配的数组
QScopedArrayPointer<char> buffer(new char[chunkSize]);
// 错误(原代码):QScopedPointer 使用 delete 释放,与 new[] 不匹配
// QScopedPointer<char> buffer(new char[chunkSize]);本报告由 AI 代码审查工具自动生成 |
Problem
The UT server run (
tests/test-prj-running.sh, ASan on) aborted the wholedeepin-log-viewer-testbinary atUT_DLDBusHandler.exportLog_home_file_copy_succeeds:Because the process aborted, no gcov data was flushed for the main suite, so the reported coverage collapsed to the plugin binary's numbers (66 tests, ~10% lines).
Root cause
Three export paths allocate copy buffers with
new char[]but hold them inQScopedPointer<char>, whose destructor calls scalardelete— undefined behavior:application/dbusproxy/dldbushandler.cpp:356logViewerService/logviewerservice.cpp:1256logViewerService/logviewerservice.cpp:1430(The latter two are the same defect flagged by the earlier Mode-5 review of
exportLog.)Fix
Switch to
QScopedArrayPointer<char>(same header, frees withdelete[]);data()usage unchanged. No ASan option masking needed.Verified: the crashing test plus the
LogViewerServiceexport tests (8 cases total) pass with plainASAN_OPTIONS=detect_leaks=0.Summary by Sourcery
Correct export buffer ownership so log export paths safely release dynamically allocated arrays and no longer abort under AddressSanitizer.
Bug Fixes:
Tests: