Add a safety check for number of control points in PolyBezierTo

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Add a safety check for number of control points in PolyBezierTo

Dmitry Timoshkov
Hello,

PolyBezier already has a similar check.

Changelog:
    Dmitry Timoshkov <[hidden email]>
    Add a safety check for number of control points in PolyBezierTo.

--- cvs/hq/wine/dlls/gdi/painting.c 2004-09-08 17:35:53.000000000 +0900
+++ wine/dlls/gdi/painting.c 2005-10-11 18:40:39.000000000 +0900
@@ -736,9 +736,13 @@ BOOL WINAPI PolyBezier( HDC hdc, const P
  */
 BOOL WINAPI PolyBezierTo( HDC hdc, const POINT* lppt, DWORD cPoints )
 {
-    DC * dc = DC_GetDCUpdate( hdc );
+    DC * dc;
     BOOL ret;
 
+    /* cbPoints must be 3 * n (where n>=1) */
+    if (!cPoints || (cPoints % 3) != 0) return FALSE;
+
+    dc = DC_GetDCUpdate( hdc );
     if(!dc) return FALSE;
 
     if(PATH_IsPathOpen(dc->path))
@@ -1110,8 +1114,8 @@ POINT *GDI_Bezier( const POINT *Points,
     POINT *out;
     INT Bezier, dwOut = BEZIER_INITBUFSIZE, i;
 
-    if((count - 1) % 3 != 0) {
-        ERR("Invalid no. of points\n");
+    if (count == 1 || (count - 1) % 3 != 0) {
+        ERR("Invalid no. of points %d\n", count);
  return NULL;
     }
     *nPtsOut = 0;