Remove old-style extern declaration that conflicts with stdlib.h.
Continues modernization for GCC compatibility.
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
Remove old-style extern declaration that conflicts with stdlib.h.
This fixes compilation error with modern GCC versions.
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
Commit 419ca82d57 (Fix m17n backspace handling causes out-of-bounds
write in checkType) introduced an incomplete fix.
In function checkType we store the length of the previous multi-char
character in a buffer plens_buffer with pointer plens pointing to the
current position inside the buffer. When encountering a backspace plens
is set to the previous position without a bounds check. This will lead
to plens being out of bounds if we get more backspaces than we have
processed multi-char characters before.
If we are at the beginning of the buffer do not decrement and set plen
(the current length) to 0.
This also fixes GH Issue #270 [BUG] Out of bound read in Strnew_size ,
Str.c:61
If the above explanation does sound weird it's because I didn't fully
grok that function. :-)
When building with gcc and -Wnull-dereference, -O3 and -flto we get a
lot of warnings about potential null dereferences. Exiting instead of
returning NULL solves all of it.
If we cannot alloc memory, there is not much to do - exiting is the
easiest option.
Introduce a separate TU for utility functions util.c. Add a function
exec_cmd to simplify execution of system commands with error handling.
While at it, suppress a warning about unused result when executing a
shell command. As we only display the command's output we do not care
about the exit code.
This fixes Debian bug #398989[0]
[0]: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=398989
Like less, w3m can use an input preprocessor when displaying files. The
preprocessor command is taken from the environment variable LESSOPEN.
The command line in LESSOPEN should include one occurrence of the string
"%s", which will be replaced by the filename when the input preprocessor
command is invoked. Giving more than one "%s" - or a any other
conversion specifier - will lead to undefined behaviour.
Add a check to make sure the command given has only one "%s".
This fixes https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=991608