diff options
author | William S Fulton <wsf@fultondesigns.co.uk> | 2022-11-22 21:40:38 +0000 |
---|---|---|
committer | William S Fulton <wsf@fultondesigns.co.uk> | 2022-11-22 21:40:38 +0000 |
commit | ca5c68e5441fa8334381bd26ea2ff5132c26e6ab (patch) | |
tree | 534a998ffb659087da50e9ac97374e9e0b36c6c5 /Source | |
parent | 0341258af7003121cdddda78c868ea2d497f8364 (diff) | |
download | swig-ca5c68e5441fa8334381bd26ea2ff5132c26e6ab.tar.gz |
Fix seg fault handling template parameter expressions containing '>='
Similar to previous commit
Issue #1037
Diffstat (limited to 'Source')
-rw-r--r-- | Source/Swig/typeobj.c | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/Source/Swig/typeobj.c b/Source/Swig/typeobj.c index 569d2a406..584e2424b 100644 --- a/Source/Swig/typeobj.c +++ b/Source/Swig/typeobj.c @@ -1043,16 +1043,17 @@ String *SwigType_templateprefix(const SwigType *t) { * ----------------------------------------------------------------------------- */ String *SwigType_templatesuffix(const SwigType *t) { - const char *c; + const char *c, *d; c = Char(t); - while (*c) { + d = c + strlen(c); + while (d > c) { if ((*c == '<') && (*(c + 1) == '(')) { int nest = 1; c++; - while (*c && nest) { - if (*c == '<') + while ((d > c) && nest) { + if (*c == '<' && *(c + 1) == '(') nest++; - if (*c == '>') + if (*c == '>' && *(c - 1) == ')') nest--; c++; } @@ -1120,18 +1121,19 @@ String *SwigType_istemplate_only_templateprefix(const SwigType *t) { * ----------------------------------------------------------------------------- */ String *SwigType_templateargs(const SwigType *t) { - const char *c; + const char *c, *d; const char *start; c = Char(t); - while (*c) { + d = c + strlen(c); + while (d > c) { if ((*c == '<') && (*(c + 1) == '(')) { int nest = 1; start = c; c++; - while (*c && nest) { - if (*c == '<') + while ((d > c) && nest) { + if (*c == '<' && *(c + 1) == '(') nest++; - if (*c == '>') + if (*c == '>' && *(c - 1) == ')') nest--; c++; } |