summaryrefslogtreecommitdiff
path: root/gcc/objc
diff options
context:
space:
mode:
authornicola <nicola@138bc75d-0d04-0410-961f-82ee72b054a4>2010-11-29 02:17:24 +0000
committernicola <nicola@138bc75d-0d04-0410-961f-82ee72b054a4>2010-11-29 02:17:24 +0000
commit9aa91c6c0fb917a6fb87b95770599bd856cc2123 (patch)
tree05586947d8babed41bf307a1a30611c3cd1da56a /gcc/objc
parentb287cf02754d009406aafe13f9715f6ccfd64d28 (diff)
downloadgcc-9aa91c6c0fb917a6fb87b95770599bd856cc2123.tar.gz
In gcc/objc/:
2010-11-29 Nicola Pero <nicola.pero@meta-innovation.com> * objc-act.c (objc_demangle): Return immediately if the string is too short. Detect names that do not need demangling, and return them unchanged. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@167231 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/objc')
-rw-r--r--gcc/objc/ChangeLog6
-rw-r--r--gcc/objc/objc-act.c16
2 files changed, 22 insertions, 0 deletions
diff --git a/gcc/objc/ChangeLog b/gcc/objc/ChangeLog
index 1ebff02f1ca..ca2833c8800 100644
--- a/gcc/objc/ChangeLog
+++ b/gcc/objc/ChangeLog
@@ -1,3 +1,9 @@
+2010-11-29 Nicola Pero <nicola.pero@meta-innovation.com>
+
+ * objc-act.c (objc_demangle): Return immediately if the string is
+ too short. Detect names that do not need demangling, and return
+ them unchanged.
+
2010-11-27 Nicola Pero <nicola.pero@meta-innovation.com>
Implemented optional properties.
diff --git a/gcc/objc/objc-act.c b/gcc/objc/objc-act.c
index 70056d39430..09f4e6f2d1a 100644
--- a/gcc/objc/objc-act.c
+++ b/gcc/objc/objc-act.c
@@ -12399,6 +12399,22 @@ objc_demangle (const char *mangled)
{
char *demangled, *cp;
+ /* First of all, if the name is too short it can't be an Objective-C
+ mangled method name. */
+ if (mangled[0] == '\0' || mangled[1] == '\0' || mangled[2] == '\0')
+ return NULL;
+
+ /* If the name looks like an already demangled one, return it
+ unchanged. This should only happen on Darwin, where method names
+ are mangled differently into a pretty-print form (such as
+ '+[NSObject class]', see darwin.h). In that case, demangling is
+ a no-op, but we need to return the demangled name if it was an
+ ObjC one, and return NULL if not. We should be safe as no C/C++
+ function can start with "-[" or "+[". */
+ if ((mangled[0] == '-' || mangled[0] == '+')
+ && (mangled[1] == '['))
+ return mangled;
+
if (mangled[0] == '_' &&
(mangled[1] == 'i' || mangled[1] == 'c') &&
mangled[2] == '_')