Fix resource leaks and minor issues

- Close pipe fds on fork failure in ExecFile::execute
- Add exception-safe fclose in cmd_file_append via try/catch
- Add overflow guards before K/M/G bit shifts in parse_whole_value
- Fix %u format for int* in sscanf (change to %d)
- Fix typo "atter"→"after" in error message
This commit is contained in:
sirus20x6
2026-03-13 20:28:38 -05:00
committed by Jari Sundell
parent 6f27159627
commit 0aaa470053
5 changed files with 24 additions and 9 deletions
+7 -3
View File
@@ -173,9 +173,13 @@ cmd_file_append(const torrent::Object::list_type& args) {
if (output == nullptr)
throw torrent::input_error("Could not append to file '" + args.front().as_string() + "': " + std::strerror(errno));
file_print_list(++args.begin(), args.end(), output, file_print_delim_space);
fprintf(output, "\n");
try {
file_print_list(++args.begin(), args.end(), output, file_print_delim_space);
fprintf(output, "\n");
} catch (...) {
fclose(output);
throw;
}
fclose(output);
return torrent::Object();
}