mirror of
git://git.sv.gnu.org/sed
synced 2026-11-21 01:43:22 +03:00
1bc68cb4d5ea80c2d8f626e059a57c2280d9d663
Without this fix, the code would sometimes use FP after calling fclose (FP), which has undefined behavior in C. Problem found with --enable-gcc-warnings and GCC 12. * sed/execute.c (open_next_file): Do not register here, as it’s too late and this can cause the file to not be cleaned up. * sed/sed.c (G_file_to_unlink, register_cleanup_file, cancel_cleanup): Move from here to utils.c. (cleanup): Call remove_cleanup_file instead of doing it by hand. * sed/utils.c (struct open_file): Remove member temp (which was always false) and fclose_failed (which was not enough to prevent calling fclose with a bad pointer). All uses changed. (register_open_file): Do not access p->fp after it’s fclosed, as that has undefined behavior in C. Use xmalloc instead of xcalloc, since we initialize all members. (G_file_to_unlink, register_cleanup_file, cancel_cleanup): Move from utils.c to here. (remove_cleanup_file): New function. (ck_mkstemp): Fix a screwup when mkostemp succeeded but set_binary_mode or fdopen failed: we might misuse a null pointer, or forget to clean up the newly-created temp file. (ck_getdelim): Rename local to avoid confusion with global. (mark_as_fclose_failed): Remove. All uses removed. (ck_fclose): Remove entry from open_files before attempting to fclose it, so that panicking doesn’t try to fclose it again. (do_ck_fclose): New arg NAME so that there’s no need to call mark_as_fclose_failed, which inspected FP after fclosing it, which is undefined behavior. (ck_rename): Omit arg UNLINK_IF_FAIL. All callers changed. The cleanup handler removes this file now, as needed.
This is the GNU implementation of sed, the Unix stream editor. GNU Sed website: https://www.gnu.org/software/sed/ See the NEWS file for a brief summary and the ChangeLog for more detailed descriptions of changes. If you obtained this file as part of a "git clone", then see the README-hacking file. If this file came to you as part of a tar archive, then see the file INSTALL for compilation and installation instructions. See the file BUGS for instructions about reporting bugs. See the files AUTHORS and THANKS for a list of authors and other contributors. After installation run 'sed --help' or 'man sed' for short usage information, and 'info sed' for the complete manual. The manual is also available on sed's website.
Description
SED (stream editor) - неинтерактивный текстовый редактор командной строки
https://www.gnu.org/software/sed/
3 MiB
0 Stars
1 Watchers
0 Forks
Languages
Shell
43%
C
26.4%
Perl
16.5%
sed
7.3%
Makefile
5.2%
Other
1.6%