diff options
Diffstat (limited to 'meta/recipes-devtools/gcc/gcc-7.1/fix-segmentation-fault-precompiled-hdr.patch')
-rw-r--r-- | meta/recipes-devtools/gcc/gcc-7.1/fix-segmentation-fault-precompiled-hdr.patch | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/meta/recipes-devtools/gcc/gcc-7.1/fix-segmentation-fault-precompiled-hdr.patch b/meta/recipes-devtools/gcc/gcc-7.1/fix-segmentation-fault-precompiled-hdr.patch new file mode 100644 index 0000000000..c0adef6f2f --- /dev/null +++ b/meta/recipes-devtools/gcc/gcc-7.1/fix-segmentation-fault-precompiled-hdr.patch | |||
@@ -0,0 +1,49 @@ | |||
1 | |||
2 | Prevent a segmentation fault which occurs when using incorrect | ||
3 | structure trying to access name of some named operators, such as | ||
4 | CPP_NOT, CPP_AND etc. "token->val.node.spelling" cannot be used in | ||
5 | those cases, as is may not be initialized at all. | ||
6 | |||
7 | |||
8 | [YOCTO #11738] | ||
9 | |||
10 | Upstream-Status: Pending | ||
11 | |||
12 | Signed-off-by: Juro Bystricky <juro.bystricky@intel.com> | ||
13 | |||
14 | diff --git a/libcpp/lex.c b/libcpp/lex.c | ||
15 | --- a/libcpp/lex.c | ||
16 | +++ b/libcpp/lex.c | ||
17 | @@ -3229,11 +3229,27 @@ | ||
18 | spell_ident: | ||
19 | case SPELL_IDENT: | ||
20 | if (forstring) | ||
21 | - { | ||
22 | - memcpy (buffer, NODE_NAME (token->val.node.spelling), | ||
23 | - NODE_LEN (token->val.node.spelling)); | ||
24 | - buffer += NODE_LEN (token->val.node.spelling); | ||
25 | - } | ||
26 | + { | ||
27 | + if (token->type == CPP_NAME) | ||
28 | + { | ||
29 | + memcpy (buffer, NODE_NAME (token->val.node.spelling), | ||
30 | + NODE_LEN (token->val.node.spelling)); | ||
31 | + buffer += NODE_LEN (token->val.node.spelling); | ||
32 | + break; | ||
33 | + } | ||
34 | + /* NAMED_OP, cannot use node.spelling */ | ||
35 | + if (token->flags & NAMED_OP) | ||
36 | + { | ||
37 | + const char *str = cpp_named_operator2name (token->type); | ||
38 | + if (str) | ||
39 | + { | ||
40 | + size_t len = strlen(str); | ||
41 | + memcpy(buffer, str, len); | ||
42 | + buffer += len; | ||
43 | + } | ||
44 | + break; | ||
45 | + } | ||
46 | + } | ||
47 | else | ||
48 | buffer = _cpp_spell_ident_ucns (buffer, token->val.node.node); | ||
49 | break; | ||