[PyObjC-svn] r2176 - in trunk/pyobjc/pyobjc-core: Lib/objc Modules/objc

[email protected]
Newsgroups gmane.comp.python.pyobjc.cvs
Message-ID <[email protected]>
Author: ronaldoussoren
Date: Tue Apr 28 06:50:37 2009
New Revision: 2176

Log:
Don't crash on invalid bridgesupport files, patch by James Eagan <James(dot)Eagan(at)lri(dot)fr>


Modified:
   trunk/pyobjc/pyobjc-core/Lib/objc/_bridgesupport.py
   trunk/pyobjc/pyobjc-core/Modules/objc/parsexml.m

Modified: trunk/pyobjc/pyobjc-core/Lib/objc/_bridgesupport.py
==============================================================================
--- trunk/pyobjc/pyobjc-core/Lib/objc/_bridgesupport.py	(original)
+++ trunk/pyobjc/pyobjc-core/Lib/objc/_bridgesupport.py	Tue Apr 28 06:50:37 2009
@@ -54,8 +54,11 @@
 
 def _parseBridgeSupport(data, globals, frameworkName, *args, **kwds):
     try:
-        objc.parseBridgeSupport(data, globals, frameworkName, *args, **kwds)
-
+        try:
+            objc.parseBridgeSupport(data, globals, frameworkName, *args, **kwds)
+        except objc.internal_error, e:
+            import warnings
+            warnings.warn("Error parsing BridgeSupport data for %s: %s" % (frameworkName, e), RuntimeWarning)
     finally:
         # Add formal protocols to the protocols submodule, for backward
         # compatibility with earlier versions of PyObjC

Modified: trunk/pyobjc/pyobjc-core/Modules/objc/parsexml.m
==============================================================================
--- trunk/pyobjc/pyobjc-core/Modules/objc/parsexml.m	(original)
+++ trunk/pyobjc/pyobjc-core/Modules/objc/parsexml.m	Tue Apr 28 06:50:37 2009
@@ -99,9 +99,9 @@
 		break;
 
 	case _C_STRUCT_B:
-		while (*buf != _C_STRUCT_E && *buf && *buf++ != '=') {
+		while (buf && *buf != _C_STRUCT_E && *buf && *buf++ != '=') {
 		}
-		while (*buf && *buf != _C_STRUCT_E) {
+		while (buf && *buf && *buf != _C_STRUCT_E) {
 			if (*buf == '"') {
 				/* embedded field name */
 				buf = strchr(buf+1, '"');
@@ -116,9 +116,9 @@
 		break;
 
 	case _C_UNION_B:
-		while (*buf != _C_UNION_E && *buf && *buf++ != '=') {
+		while (buf && *buf != _C_UNION_E && *buf && *buf++ != '=') {
 		}
-		while (*buf && *buf != _C_UNION_E) {
+		while (buf && *buf && *buf != _C_UNION_E) {
 			if (*buf == '"') {
 				/* embedded field name */
 				buf = strchr(buf+1, '"');
@@ -144,7 +144,14 @@
 {
 	while (buf && *buf) {
 		typecode2typecode(buf);
-		buf = (char*)PyObjCRT_SkipTypeSpec(buf);
+		if (buf && *buf == '\"') {
+			PyErr_Format(PyObjCExc_InternalError,
+				"typecode2typecode: invalid typecode '%c' at \"%s\"", 
+				*buf, buf);
+			*buf = '\0';
+		} else {
+			buf = (char*)PyObjCRT_SkipTypeSpec(buf);
+		}
 	}
 }
 

------------------------------------------------------------------------------
Register Now & Save for Velocity, the Web Performance & Operations 
Conference from O'Reilly Media. Velocity features a full day of 
expert-led, hands-on workshops and two days of sessions from industry 
leaders in dedicated Performance & Operations tracks. Use code vel09scf 
and Save an extra 15% before 5/3. http://p.sf.net/sfu/velocityconf
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.