mirror of
https://github.com/DreamMaoMao/maomaowm.git
synced 2026-05-02 06:46:29 -04:00
Polish security fixes with minor improvements
- Remove redundant null termination for short strings - Use descriptive variable names in cleanup loop - Cache strlen results to avoid O(n²) complexity in string concatenation - Add bounds checks before string operations Co-authored-by: squassina <8495707+squassina@users.noreply.github.com>
This commit is contained in:
parent
e2649dd84f
commit
12fe0abca1
3 changed files with 12 additions and 7 deletions
|
|
@ -863,9 +863,9 @@ int32_t spawn(const Arg *arg) {
|
|||
execvp(argv[0], argv);
|
||||
|
||||
// 4. execvp 失败时:清理分配的字符串并打印错误
|
||||
for (int i = 0; i < argc; i++) {
|
||||
if (argv_allocated[i]) {
|
||||
free(argv[i]);
|
||||
for (int arg_idx = 0; arg_idx < argc; arg_idx++) {
|
||||
if (argv_allocated[arg_idx]) {
|
||||
free(argv[arg_idx]);
|
||||
}
|
||||
}
|
||||
wlr_log(WLR_ERROR, "mango: execvp '%s' failed: %s\n", argv[0],
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue