StringsPlugin: a line's end cut off without reading past it

load_string() put a NUL where a line read from the file had its CR or
LF, and stepped over it as well as over the character after: past the
line's NUL terminator, into what was left in the buffer from longer
lines before, or past its end, writing NULs wherever it found CR or LF.
The line is cut at its first CR or LF instead.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit e396da2696)
This commit is contained in:
Vladimir Dubrovin 2026-10-28 12:01:35 +03:00
parent 371e78691d
commit 9be415b731

View File

@ -61,14 +61,9 @@ char **load_string(FILE *f,int max_count_str, int *countloadstr,
if (strstr(tmpbuf1,"[end]")==NULL)
{
/* find and replace \n \r*/
rstr = tmpbuf1;
while (*rstr!='\0')
{
if (*rstr=='\r' || *rstr=='\n' )
{ *rstr='\0'; rstr++; }
rstr++;
}
/* the line's end cut off: what the file says with \n is what is
sent */
tmpbuf1[strcspn(tmpbuf1, "\r\n")] = '\0';
while ((rstr=strstr(tmpbuf1,"\\n")))
{