[2/2] d3dx9: Implement D3DXLoadMeshHierarchy for basic mesh hierarchy.

Dylan Smith dylan.ah.smith at gmail.com
Thu May 19 11:34:08 CDT 2011


On Thu, May 19, 2011 at 6:16 AM, Joris Huizer <joris_huizer at yahoo.com> wrote:
>
> Hello,
>
> I found a possibly memory leak in the patch.
> In this function:
>
>> +static HRESULT parse_mesh(IDirectXFileData *filedata, struct mesh_data *mesh_data, DWORD provide_flags)
>
> These may leak the allocated blocks:
>>
>> +
>> +    mesh_data->vertices = HeapAlloc(GetProcessHeap(), 0,
>> +            mesh_data->num_vertices * sizeof(*mesh_data->vertices));
>> +    mesh_data->num_tri_per_face = HeapAlloc(GetProcessHeap(), 0,
>> +            mesh_data->num_poly_faces * sizeof(*mesh_data->num_tri_per_face));
>> +    mesh_data->indices = HeapAlloc(GetProcessHeap(), 0,
>> +            (mesh_data->num_tri_faces + mesh_data->num_poly_faces * 2) * sizeof(*mesh_data->indices));
>> +    if (!mesh_data->vertices || !mesh_data->num_tri_per_face || !mesh_data->indices)
>> +        return E_OUTOFMEMORY;
>> +
>

All the pointers are stored in mesh_data, which isn't lost. They are
freed at the end of load_skin_mesh_from_xof.

+cleanup:
+    if (FAILED(hr)) {
+        if (d3dxmesh) IUnknown_Release(d3dxmesh);
+        if (adjacency) ID3DXBuffer_Release(adjacency);
+    }
+    HeapFree(GetProcessHeap(), 0, mesh_data.vertices);
+    HeapFree(GetProcessHeap(), 0, mesh_data.num_tri_per_face);
+    HeapFree(GetProcessHeap(), 0, mesh_data.indices);
+    return hr;
+}



More information about the wine-devel mailing list