[1/3] gdiplus: Fix GdipCreatePathIter to handle NULL as path. Fix tests (try3)

Nikolay Sivov bunglehead at gmail.com
Sun Jul 13 02:52:12 CDT 2008


Changelog:
    - Fix GdipCreatePathIter to handle NULL as path
    - Fix tests

---
 dlls/gdiplus/pathiterator.c       |   32 +++++++++++++++++++++-----------
 dlls/gdiplus/tests/pathiterator.c |    2 +-
 2 files changed, 22 insertions(+), 12 deletions(-)

diff --git a/dlls/gdiplus/pathiterator.c b/dlls/gdiplus/pathiterator.c
index 026665a..55b0782 100644
--- a/dlls/gdiplus/pathiterator.c
+++ b/dlls/gdiplus/pathiterator.c
@@ -31,24 +31,30 @@ GpStatus WINGDIPAPI GdipCreatePathIter(GpPathIterator **iterator, GpPath* path)
 {
     INT size;
 
-    if(!iterator || !path)
+    if(!iterator)
         return InvalidParameter;
 
-    size = path->pathdata.Count;
-
     *iterator = GdipAlloc(sizeof(GpPathIterator));
     if(!*iterator)  return OutOfMemory;
 
-    (*iterator)->pathdata.Types = GdipAlloc(size);
-    (*iterator)->pathdata.Points = GdipAlloc(size * sizeof(PointF));
+    if(path){
+        size = path->pathdata.Count;
 
-    memcpy((*iterator)->pathdata.Types, path->pathdata.Types, size);
-    memcpy((*iterator)->pathdata.Points, path->pathdata.Points,
-           size * sizeof(PointF));
-    (*iterator)->pathdata.Count = size;
+        (*iterator)->pathdata.Types  = GdipAlloc(size);
+        (*iterator)->pathdata.Points = GdipAlloc(size * sizeof(PointF));
 
-    (*iterator)->subpath_pos = 0;
-    (*iterator)->marker_pos = 0;
+        memcpy((*iterator)->pathdata.Types, path->pathdata.Types, size);
+        memcpy((*iterator)->pathdata.Points, path->pathdata.Points,size * sizeof(PointF));
+        (*iterator)->pathdata.Count = size;
+    }
+    else{
+        (*iterator)->pathdata.Types  = NULL;
+        (*iterator)->pathdata.Points = NULL;
+        (*iterator)->pathdata.Count  = 0;
+    }
+
+    (*iterator)->subpath_pos  = 0;
+    (*iterator)->marker_pos   = 0;
     (*iterator)->pathtype_pos = 0;
 
     return Ok;
@@ -156,6 +162,10 @@ GpStatus WINGDIPAPI GdipPathIterNextSubpath(GpPathIterator* iterator,
 
     count = iterator->pathdata.Count;
 
+    /* iterator created with NULL path */
+    if(count == 0)
+        return Ok;
+
     if(iterator->subpath_pos == count){
         *startIndex = *endIndex = *resultCount = 0;
         *isClosed = 1;
diff --git a/dlls/gdiplus/tests/pathiterator.c b/dlls/gdiplus/tests/pathiterator.c
index 385be88..071c1d5 100644
--- a/dlls/gdiplus/tests/pathiterator.c
+++ b/dlls/gdiplus/tests/pathiterator.c
@@ -37,7 +37,7 @@ static void test_constructor_destructor(void)
     stat = GdipCreatePathIter(NULL, NULL);
     expect(InvalidParameter, stat);
     stat = GdipCreatePathIter(&iter, NULL);
-    expect(InvalidParameter, stat);
+    expect(Ok, stat);
     stat = GdipCreatePathIter(NULL, path);
     expect(InvalidParameter, stat);
     stat = GdipDeletePathIter(NULL);
-- 
1.4.4.4






More information about the wine-patches mailing list