Infinite loop in D3D_GL_draw patch

Marius Grigoriu <[email protected]> Wed, 18 Aug 2004 13:35:26 -0400
Newsgroups gmane.comp.emulators.winex.devel
Message-ID <[email protected]>
If the feedback buffer estimate is ever wrong, it would result in an 
infinite loop. Even though feedback_size is doubled, it is later 
overwritten by the original value, so the code never escapes this sequence.

My patch adds a new goto label to preserve the modified value of 
feedback_size. I also removed the memory allocation before the goto 
because it is unnecessary since it is done anyway just before TRACE(start)

Marius Grigoriu
prim.patch (text/x-patch, 956 B)
? prim.patch
Index: prim.c
===================================================================
RCS file: /cvsroot/winex/dlls/d3dgl/prim.c,v
retrieving revision 1.50
diff -u -r1.50 prim.c
--- prim.c	6 Apr 2004 16:43:59 -0000	1.50
+++ prim.c	18 Aug 2004 17:23:23 -0000
@@ -264,6 +264,7 @@
 	 */
 	unsigned mp = (pt == GL_POINTS) ? 3 : 16;
 	feedback_size = mp*(cmd->u.wPrimitiveCount+2);
+feedback_restart:
 	if (intercept) {
 	    GLfloat proj_mat[16];
 	    GLint view[4];
@@ -337,10 +338,7 @@
 	    /* try again with larger feedback buffer */
 	    HeapFree(GetProcessHeap(), 0, feedback);
 	    feedback_size *= 2;
-	    feedback = HeapAlloc(GetProcessHeap(), 0, feedback_size*sizeof(GLfloat));
-	    glFeedbackBuffer(feedback_size, GL_2D, feedback);
-	    glRenderMode(GL_FEEDBACK);
-	    goto render_start;
+	    goto feedback_restart;
 #else
 	    /* alternatively, we could just go with what we have,
 	     * but I'm not sure if that would work. */