Closed remicollet closed 1 year ago
Perhaps the proper fix is to close the input file only if it was open by the function ?
- if (subtask->input.file)
+ if (subtask->input.file && subtask->input.name && subtask->input.name[0])
Or to add a "openbyme" flag in the task struct to check if it need to be closed
Notice: when name is empty, stdin
is used, and closing it may have strange unexpected results.
FYI also reported to Fedora package owner as bug #2170818
Thanks @remicollet for the report, and for the fix, which looks good to me, and I've committed.
I will make another release shortly.
Thanks. I confirm 2.7.13 (in Fedora 38) + https://github.com/rrthomas/recode/commit/80516f601ce5f1cee44848615dffe4252f2d205f properly fix this issue.
Using
recode_file_to_file
a double free occurs because of closing the provided file handleI think
recode_file_to_file
should not close file handles given by the caller This is caller work (open + close)Regression introduce in 2.7.13 in 951bdbc2d847e583e4bc62a997a00058bb75d541
Reverting this commit fixes the issue.
Found when running PHP recode extension.
Segfault happens when PHP closes the stream it has open before calling recode_file_to_file