Module: wine Branch: master Commit: dcfbe58ef7cf852f7acceb4182eb87827d0eceae URL: http://source.winehq.org/git/wine.git/?a=commit;h=dcfbe58ef7cf852f7acceb4182...
Author: Nikolay Sivov bunglehead@gmail.com Date: Sun Jul 13 11:52:12 2008 +0400
gdiplus: 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);