ecere/com: Improved on virtual table protection code
authorJerome St-Louis <jerome@ecere.com>
Mon, 15 Apr 2013 05:29:10 +0000 (01:29 -0400)
committerJerome St-Louis <jerome@ecere.com>
Mon, 15 Apr 2013 05:29:10 +0000 (01:29 -0400)
- Fixed > to read >=
- Added in AddVirtualMethod() in addition to AddMethod()
- Improved warning message

ecere/src/com/instance.ec

index d44a9b6..fe560ef 100644 (file)
@@ -3995,8 +3995,8 @@ public dllexport Method eClass_AddMethod(Class _class, char * name, char * type,
             {
                OldLink deriv;
                void * oldFunction = _class._vTbl[method.vid];
-               if(method.vid > _class.vTblSize)
-                  printf("error");
+               if(method.vid >= _class.vTblSize)
+                  printf("error: virtual methods overriding failure\n");
                else
                   _class._vTbl[method.vid] = function ? function : DefaultFunction;
                for(deriv = _class.derivatives.first; deriv; deriv = deriv.next)
@@ -4063,7 +4063,12 @@ public dllexport Method eClass_AddVirtualMethod(Class _class, char * name, char
          {
             // If this overides a virtual method
             if(method.type == virtualMethod)
-               _class._vTbl[method.vid] = function ? function : DefaultFunction;
+            {
+               if(method.vid >= _class.vTblSize)
+                  printf("error: virtual methods overriding failure\n");
+               else
+                  _class._vTbl[method.vid] = function ? function : DefaultFunction;
+            }
             else
                base = null;
             return method;