summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--NEWS5
-rw-r--r--filter.c37
-rw-r--r--flex.skl7
3 files changed, 40 insertions, 9 deletions
diff --git a/NEWS b/NEWS
index d790bdf..2fa6515 100644
--- a/NEWS
+++ b/NEWS
@@ -5,6 +5,11 @@ See the file COPYING for copying conditions.
* after version 2.5.33
+** flex better escapes filenames with special characters in them
+(resolves#1623600)
+
+** a memory leak was plugged(resolves bug #1601111)
+
** pattern language expanded; see the manual for details on the below
highlights
diff --git a/filter.c b/filter.c
index 54fa50c..b0c7bf1 100644
--- a/filter.c
+++ b/filter.c
@@ -354,24 +354,43 @@ int filter_fix_linedirs (struct filter *chain)
num = regmatch_strtol (&m[1], buf, NULL, 0);
fname = regmatch_dup (&m[2], buf);
- if (strcmp
- (fname, outfilename ? outfilename : "<stdout>")
- == 0
- || strcmp (fname,
- headerfilename ? headerfilename :
- "<stdout>") == 0) {
+ if (strcmp (fname,
+ outfilename ? outfilename : "<stdout>")
+ == 0
+ || strcmp (fname,
+ headerfilename ? headerfilename : "<stdout>")
+ == 0) {
+
+ char *s1, *s2;
+ char filename[MAXLINE];
+
+ s1 = fname;
+ s2 = filename;
+
+ while ((s2 - filename) < (MAXLINE - 1) && *s1) {
+ /* Escape the backslash */
+ if (*s1 == '\\')
+ *s2++ = '\\';
+ /* Escape the double quote */
+ if (*s1 == '\"')
+ *s2++ = '\\';
+ /* Copy the character as usual */
+ *s2++ = *s1++;
+ }
+
+ *s2 = '\0';
+
/* Adjust the line directives. */
in_gen = true;
snprintf (buf, readsz, "#line %d \"%s\"\n",
- lineno + 1, fname);
- free (fname);
-
+ lineno + 1, filename);
}
else {
/* it's a #line directive for code we didn't write */
in_gen = false;
}
+ free (fname);
last_was_blank = false;
}
diff --git a/flex.skl b/flex.skl
index 3cf3064..4ab57c9 100644
--- a/flex.skl
+++ b/flex.skl
@@ -1647,6 +1647,13 @@ m4_ifdef( [[M4_YY_USES_REJECT]],
else
ret_val = EOB_ACT_CONTINUE_SCAN;
+ if ((yy_size_t) (yy_n_chars + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) {
+ /* Extend the array by 50%, plus the number we really need. */
+ yy_size_t new_size = yy_n_chars + number_to_move + (yy_n_chars >> 1);
+ YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) yyrealloc(
+ (void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf, new_size);
+ }
+
YY_G(yy_n_chars) += number_to_move;
YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[YY_G(yy_n_chars)] = YY_END_OF_BUFFER_CHAR;
YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[YY_G(yy_n_chars) + 1] = YY_END_OF_BUFFER_CHAR;