diff --git a/dlls/d3dxof/d3dxof.c b/dlls/d3dxof/d3dxof.c
index 7ce820897f33783704efdf4642e109ae523a4f72..3ba92e2f44212fcfa8440629249cfc89c1f45df9 100644
--- a/dlls/d3dxof/d3dxof.c
+++ b/dlls/d3dxof/d3dxof.c
@@ -661,11 +661,15 @@ static HRESULT WINAPI IDirectXFileDataImpl_GetNextObject(IDirectXFileData* iface
   TRACE("(%p/%p)->(%p)\n", This, iface, ppChildObj);
 
   if (This->cur_enum_object >= This->pobj->nb_children)
+  {
+    *ppChildObj = NULL;
     return DXFILEERR_NOMOREOBJECTS;
+  }
 
   if (This->from_ref && (This->level >= 1))
   {
     /* Only 2 levels can be enumerated if the object is obtained from a reference */
+    *ppChildObj = NULL;
     return DXFILEERR_NOMOREOBJECTS;
   }