[comp.windows.x] bug in R4 Intrinsics

zjmw36@trc.amoco.COM (Joe M. Wade) (05/03/91)

I have found what I believe to be a bug in the R4 intrinsics. The code which I 
believe is suspect is in the subroutine _XtDoPhase2Destroy in the Destroy.c
source. When destroying a widget from within this routine, it is being removed
from the app->destroy_list and the list is shifted down. However, the byte
count on the list shift appears to be in error. It is currently shifting 
app->destroy_count items down starting at the location following the one 
being removed. In the case of my program, that caused the shifting of my
widget's structure. I believe the actual number of items copied should be
app->destroy_count-i, where i is the location of the one being removed. This
is after app->destroy_count has been decremented.

Here's the subroutine:


void _XtDoPhase2Destroy(app, dispatch_level)
    XtAppContext app;
    int dispatch_level;
{
    /* Phase 2 must occur in fifo order.  List is not necessarily
     * contiguous in dispatch_level.
     */

    int i = 0;
    DestroyRec* dr = app->destroy_list;

    while (i < app->destroy_count) {
	if (dr->dispatch_level >= dispatch_level)  {
	    Widget w = dr->widget;
	    if (--app->destroy_count)
		bcopy( (char*)(dr+1), (char*)dr,

/*  -- here's what I believe is a bug 
		       app->destroy_count*sizeof(DestroyRec) */
		       (app->destroy_count-i)*sizeof(DestroyRec)
		      );
	    XtPhase2Destroy(w);
	}
	else {
	    i++;
	    dr++;
	}
    }
}


Making the change did cause my code to go ahead and work ( as if that's any kind of proof :->  )
Could you please let me know if this is, in fact, a bug? (if so, has it already been covered by
a patch ? )

Thx.
Joe

converse@expo.lcs.mit.EDU (Donna Converse) (05/03/91)

> I have found what I believe to be a bug in the R4 intrinsics. The code which I 
> believe is suspect is in the subroutine _XtDoPhase2Destroy in the Destroy.c
> source.

> Could you please let me know if this is, in fact, a bug?

It is a bug.

> (if so, has it already been covered by a patch ? )

No, sorry.  I think someone else once posted a patch for this to 
comp.windows.x/xpert.