Fix out of bounds memory problems in handling simple macro arguments
Fixes handling macro in swigmacros.swg: #define %arg(Arg...) Arg AddressSanitizer error running Python test-suite.
This commit is contained in:
parent
af8d176c40
commit
ab5559f51c
1 changed files with 13 additions and 11 deletions
|
|
@ -930,19 +930,21 @@ static String *expand_macro(String *name, List *args, String *line_file) {
|
||||||
namelen = Len(aname);
|
namelen = Len(aname);
|
||||||
a = strstr(s, name);
|
a = strstr(s, name);
|
||||||
while (a) {
|
while (a) {
|
||||||
char ca = a[namelen + 1];
|
char ca = a[namelen];
|
||||||
if (!isidchar((int) ca)) {
|
if (!isidchar((int) ca)) {
|
||||||
/* Matched the entire vararg name, not just a prefix */
|
/* Matched the entire vararg name, not just a prefix */
|
||||||
t = a - 1;
|
if (a > s) {
|
||||||
if (*t == '\002') {
|
t = a - 1;
|
||||||
t--;
|
if (*t == '\002') {
|
||||||
while (t >= s) {
|
t--;
|
||||||
if (isspace((int) *t))
|
while (t >= s) {
|
||||||
t--;
|
if (isspace((int) *t))
|
||||||
else if (*t == ',') {
|
t--;
|
||||||
*t = ' ';
|
else if (*t == ',') {
|
||||||
} else
|
*t = ' ';
|
||||||
break;
|
} else
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue