For some reason, lex decided to reduce a strcpy into an assignment,
leading to entirely justified valgrind warnings about invalid reads,
when scanFile was set to a string which may have only ever lived on the
stack of a now-exited function.
Make it a strdup() instead.
Signed-off-by: Daniel Stone <daniel@fooishbar.org>
XkbDirectoryForInclude(file_type));
return False;
}
- strcpy(oldFile, scanFile);
+ if (scanFile)
+ strcpy(oldFile, scanFile);
+ else
+ memset(oldFile, 0, sizeof(oldFile));
oldLine = lineNum;
setScanState(stmt->file, 1);
if (debugFlags & 2)
#include "parseutils.h"
const char *yystring;
-static char scanFileBuf[1024] = {0};
-char *scanFile = scanFileBuf;
+char *scanFile = NULL;
int lineNum = 0;
int scanInt;
void setScanState(char *file, int lineno)
{
yylineno = 1;
- strncpy(scanFile, file, 1023);
- scanFile[1023]='\0';
+ if (scanFile)
+ free(scanFile);
+ scanFile = strdup(file);
}
int