Warn on null this pointer.
authorJosé Fonseca <jose.r.fonseca@gmail.com>
Thu, 5 Apr 2012 18:58:20 +0000 (19:58 +0100)
committerJosé Fonseca <jose.r.fonseca@gmail.com>
Thu, 5 Apr 2012 18:58:20 +0000 (19:58 +0100)
retrace.py

index 96a53b3..b2d8f2f 100644 (file)
@@ -286,8 +286,12 @@ class Retracer:
         self.swizzleValues(method)
 
     def deserializeThisPointer(self, interface):
-        print '    %s *_this;' % (interface.name,)
-        print '    _this = static_cast<%s *>(_obj_map[call.arg(0).toUIntPtr()]);' % (interface.name,)
+        print r'    %s *_this;' % (interface.name,)
+        print r'    _this = static_cast<%s *>(_obj_map[call.arg(0).toUIntPtr()]);' % (interface.name,)
+        print r'    if (!_this) {'
+        print r'        retrace::warning(call) << "NULL this pointer\n";'
+        print r'        return;'
+        print r'    }'
 
     def deserializeArgs(self, function):
         print '    retrace::ScopedAllocator _allocator;'