Commit 3602d0a
authored
Fix multiple memory leaks in Region::process() function (flameshot-org#4284)
* Fix multiple memory leaks in Region::process() function
- Add proper cleanup for allocated QApplication object
- Add proper cleanup for allocated char** argv array
- Add proper cleanup for allocated int* argc pointer
- Ensure all return paths properly clean up allocated memory
- Prevents memory leaks when Region::process() is called
Fixes multiple memory leaks identified in codebase analysis.
* Apply clang-format to fix code style compliance
- Remove trailing whitespace
- Normalize line endings
- Ensure compliance with project's clang-format rules
Fixes CI test-clang-format workflow failure.
* Refactor cleanup logic in Region::process
Introduced a cleanup lambda to handle memory deallocation in Region::process, replacing repeated code with a single reusable function for better maintainability and readability.
* Format cleanup lambda for readability
Reformatted the cleanup lambda in Region::process for improved readability by expanding it to multiple lines.
* Refactor Region::process to use smart pointers
Replaces manual memory management with std::unique_ptr for temporary QApplication and argument variables. Removes redundant cleanup logic for improved safety and readability.1 parent 5b0ee2f commit 3602d0a
1 file changed
+5
-3
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
| 13 | + | |
13 | 14 | | |
14 | 15 | | |
15 | 16 | | |
| |||
530 | 531 | | |
531 | 532 | | |
532 | 533 | | |
533 | | - | |
534 | | - | |
| 534 | + | |
| 535 | + | |
| 536 | + | |
535 | 537 | | |
536 | | - | |
| 538 | + | |
537 | 539 | | |
538 | 540 | | |
539 | 541 | | |
| |||
0 commit comments