Commit 3838e80
fix(docparser): prevent exception escape in doConvertFile from aborting host process
- Move createParser() call and nullptr check inside the try block in doConvertFile() so parser constructor exceptions are
also caught
- Replace throwing std::logic_error with a log + return {} for unsupported extensions, aligning with
tryConvertWithTruncation()
- Prevents std::logic_error from escaping DocParser::convertFile, which previously triggered std::terminate -> abort in
callers without try-catch (e.g. dde-file-manager TextExtractor::extract)
- Add binary test file test_crash_unsupported_ext.dat to reproduce/regress the unsupported-extension crash path
修复(docparser): 防止 doConvertFile 中异常逃逸导致宿主进程崩溃
- 将 createParser() 调用和 nullptr 检查移入 doConvertFile() 的 try 块内,确保解析器构造期异常也被捕获
- 不支持的扩展名由抛出 std::logic_error 改为打印日志并返回空串,与 tryConvertWithTruncation() 写法保持一致
- 防止 std::logic_error 从 DocParser::convertFile 逃逸,原先会在无 try-catch 的调用方(如 dde-file-manager 的
TextExtractor::extract)触发 std::terminate -> abort
- 新增二进制测试文件 test_crash_unsupported_ext.dat,用于复现/回归不支持扩展名的崩溃路径
Log: 修复 doConvertFile 中异常逃逸导致宿主进程 std::terminate -> abort
的问题,将不支持扩展名的处理由抛异常改为返回空串,并把 createParser 调用纳入 try 保护
Task: https://pms.uniontech.com/task-view-391293.html1 parent 4ac50cd commit 3838e80
2 files changed
Lines changed: 11 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
283 | 283 | | |
284 | 284 | | |
285 | 285 | | |
286 | | - | |
287 | | - | |
288 | | - | |
289 | | - | |
290 | | - | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
291 | 291 | | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
292 | 298 | | |
293 | 299 | | |
294 | 300 | | |
| |||
Binary file not shown.
0 commit comments