Zebediah Figura : devenum: Call DMOGetTypes() until less types are returned than were allocated.

Alexandre Julliard julliard at winehq.org
Mon Jul 13 16:08:49 CDT 2020


Module: wine
Branch: master
Commit: 58c3b5c100046395670ee986b99d5be849c29048
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=58c3b5c100046395670ee986b99d5be849c29048

Author: Zebediah Figura <z.figura12 at gmail.com>
Date:   Mon Jul 13 09:38:05 2020 -0500

devenum: Call DMOGetTypes() until less types are returned than were allocated.

Signed-off-by: Zebediah Figura <z.figura12 at gmail.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/devenum/mediacatenum.c | 25 ++++++++++++-------------
 1 file changed, 12 insertions(+), 13 deletions(-)

diff --git a/dlls/devenum/mediacatenum.c b/dlls/devenum/mediacatenum.c
index 16b729ab1f..ab675b5656 100644
--- a/dlls/devenum/mediacatenum.c
+++ b/dlls/devenum/mediacatenum.c
@@ -147,28 +147,27 @@ static HRESULT WINAPI property_bag_Read(IPropertyBag *iface,
             };
 
             unsigned int count = 1, input_count, output_count, i;
-            DMO_PARTIAL_MEDIATYPE *types = NULL;
+            DMO_PARTIAL_MEDIATYPE *types = NULL, *new_array;
             REGPINTYPES *reg_types;
             HRESULT hr;
 
-            if (!(types = malloc(2 * count * sizeof(*types))))
-                return E_OUTOFMEMORY;
-
-            while ((hr = DMOGetTypes(&moniker->clsid, count, &input_count, types,
-                    count, &output_count, types + count)) == S_FALSE)
+            do
             {
                 count *= 2;
-                if (!(types = realloc(types, count * sizeof(*types))))
+                if (!(new_array = realloc(types, 2 * count * sizeof(*types))))
                 {
                     free(types);
                     return E_OUTOFMEMORY;
                 }
-            }
-            if (hr != S_OK)
-            {
-                free(types);
-                return hr;
-            }
+                types = new_array;
+
+                if (FAILED(hr = DMOGetTypes(&moniker->clsid, count, &input_count, types,
+                        count, &output_count, types + count)))
+                {
+                    free(types);
+                    return hr;
+                }
+            } while (input_count == count || output_count == count);
 
             if (!(reg_types = malloc(2 * count * sizeof(*reg_types))))
             {




More information about the wine-cvs mailing list