summaryrefslogtreecommitdiff
path: root/Source
diff options
context:
space:
mode:
authorWilliam S Fulton <wsf@fultondesigns.co.uk>2022-11-22 08:30:39 +0000
committerWilliam S Fulton <wsf@fultondesigns.co.uk>2022-11-22 08:37:35 +0000
commit0341258af7003121cdddda78c868ea2d497f8364 (patch)
tree0b9415364f9939a3445494b1733a187879e3d1e9 /Source
parent29bc7492a2ec300997eaf670bf24f1556fef08cd (diff)
downloadswig-0341258af7003121cdddda78c868ea2d497f8364.tar.gz
Fix seg fault handling template parameter expressions containing '<='
Recent commits ensure types are correctly stored in SwigType *. In particular template parameters are enclosed within '<(' and ')>'. Now we can confidently handle template parameters as really being delimited as such to fix an infinite loop handling template expressions containing '<' or '>'. The previous implementation only assumed template parameters were delimited by '<' and '>'. Issue #1037
Diffstat (limited to 'Source')
-rw-r--r--Source/Swig/typeobj.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/Source/Swig/typeobj.c b/Source/Swig/typeobj.c
index 8cd2e28e9..569d2a406 100644
--- a/Source/Swig/typeobj.c
+++ b/Source/Swig/typeobj.c
@@ -1234,17 +1234,20 @@ String *SwigType_prefix(const SwigType *t) {
while (d > c) {
d--;
- if (*d == '>') {
+ if (*d == '>' && (d > c) && *(d - 1) == ')') {
+ /* skip over template parameters */
int nest = 1;
d--;
+ d--;
while ((d > c) && (nest)) {
- if (*d == '>')
+ if (*d == '>' && *(d - 1) == ')')
nest++;
- if (*d == '<')
+ if (*d == '<' && *(d + 1) == '(')
nest--;
d--;
}
}
+
if (*d == ')') {
/* Skip over params */
int nparen = 1;
@@ -1259,10 +1262,10 @@ String *SwigType_prefix(const SwigType *t) {
}
if (*d == '.') {
- char t = *(d + 1);
+ char x = *(d + 1);
*(d + 1) = 0;
r = NewString(c);
- *(d + 1) = t;
+ *(d + 1) = x;
return r;
}
}