d3dxof: Increase MAX_SUBOBJECTS and do the corresponding checks at the right place.
authorChristian Costa <titan.costa@wanadoo.fr>
Tue, 23 Mar 2010 07:32:20 +0000 (08:32 +0100)
committerAlexandre Julliard <julliard@winehq.org>
Tue, 23 Mar 2010 11:19:49 +0000 (12:19 +0100)
dlls/d3dxof/d3dxof.c
dlls/d3dxof/d3dxof_private.h
dlls/d3dxof/parsing.c

index b8c85e0ac38b29c304cf27148a917251cb0fc0dd..507664f4f6480c7ffd5c2e507ff101f71399ef3d 100644 (file)
@@ -1104,13 +1104,6 @@ static HRESULT WINAPI IDirectXFileEnumObjectImpl_GetNextDataObject(IDirectXFileE
     goto error;
   }
 
-  if (This->buf.pxo->nb_subobjects > MAX_SUBOBJECTS)
-  {
-    FIXME("Too many subobjects %d\n", This->buf.pxo->nb_subobjects);
-    hr = DXFILEERR_BADALLOC;
-    goto error;
-  }
-
   object->pstrings = pstrings;
   object->pobj = This->buf.pxo;
   object->cur_enum_object = 0;
index 8f3b53e47f3da4ce007efba0a4e3421d15602395..a8534ac62313b672bd8b5f933b4d5607cf252375 100644 (file)
@@ -39,7 +39,7 @@
 #define MAX_CHILDS 100
 #define MAX_TEMPLATES 200
 #define MAX_OBJECTS 500
-#define MAX_SUBOBJECTS 500
+#define MAX_SUBOBJECTS 2000
 #define MAX_STRINGS_BUFFER 10000
 
 typedef struct {
index c2ffdfffb4739b15b8455bde1c0638c1be279393..c45fcd0414803ec3430bbb336bfe2023077d4c6d 100644 (file)
@@ -1212,6 +1212,13 @@ _exit:
           ERR("Reference to unknown object %s\n", (char*)buf->value);
           return FALSE;
         }
+
+        if (buf->pxo->root->nb_subobjects >= MAX_SUBOBJECTS)
+        {
+            FIXME("Too many sub-objects\n");
+            return FALSE;
+        }
+
         buf->pxo->childs[buf->pxo->nb_childs] = &buf->pxo_tab[buf->pxo->root->nb_subobjects++];
         buf->pxo->childs[buf->pxo->nb_childs]->ptarget = &(buf->pxo_globals[i])[j];
         buf->pxo->nb_childs++;
@@ -1219,6 +1226,13 @@ _exit:
       else if (check_TOKEN(buf) == TOKEN_NAME)
       {
         xobject* pxo = buf->pxo;
+
+        if (buf->pxo->root->nb_subobjects >= MAX_SUBOBJECTS)
+        {
+            FIXME("Too many sub-objects\n");
+            return FALSE;
+        }
+
         buf->pxo = buf->pxo->childs[buf->pxo->nb_childs] = &buf->pxo_tab[buf->pxo->root->nb_subobjects++];
 
         TRACE("Enter optional %s\n", (char*)buf->value);