Fix for some types of C++ debug info that can cause winedbg to crash. Dave Hawkes
Index: debugger/msc.c =================================================================== RCS file: /home/wine/wine/debugger/msc.c,v retrieving revision 1.43 diff -u -r1.43 msc.c --- debugger/msc.c 2001/08/21 17:07:17 1.43 +++ debugger/msc.c 2001/12/06 18:03:16 @@ -540,153 +540,153 @@ { struct { - short int len; - short int id; + unsigned short int len; + short int id; } generic; struct { - short int len; - short int id; - short int attribute; - short int datatype; - unsigned char variant[1]; + unsigned short int len; + short int id; + short int attribute; + short int datatype; + unsigned char variant[1]; } pointer; struct { - short int len; - short int id; - unsigned int datatype; - unsigned int attribute; - unsigned char variant[1]; + unsigned short int len; + short int id; + unsigned int datatype; + unsigned int attribute; + unsigned char variant[1]; } pointer32; struct { - short int len; - short int id; - unsigned char nbits; - unsigned char bitoff; - unsigned short type; + unsigned short int len; + short int id; + unsigned char nbits; + unsigned char bitoff; + unsigned short type; } bitfield; struct { - short int len; - short int id; - unsigned int type; - unsigned char nbits; - unsigned char bitoff; + unsigned short int len; + short int id; + unsigned int type; + unsigned char nbits; + unsigned char bitoff; } bitfield32; struct { - short int len; - short int id; - short int elemtype; - short int idxtype; - unsigned short int arrlen; /* numeric leaf */ + unsigned short int len; + short int id; + short int elemtype; + short int idxtype; + unsigned short int arrlen; /* numeric leaf */ #if 0 - unsigned char name[1]; + unsigned char name[1]; #endif } array; struct { - short int len; - short int id; - unsigned int elemtype; - unsigned int idxtype; - unsigned short int arrlen; /* numeric leaf */ + unsigned short int len; + short int id; + unsigned int elemtype; + unsigned int idxtype; + unsigned short int arrlen; /* numeric leaf */ #if 0 - unsigned char name[1]; + unsigned char name[1]; #endif } array32; struct { - short int len; - short int id; - short int n_element; - short int fieldlist; - short int property; - short int derived; - short int vshape; - unsigned short int structlen; /* numeric leaf */ + unsigned short int len; + short int id; + short int n_element; + short int fieldlist; + short int property; + short int derived; + short int vshape; + unsigned short int structlen; /* numeric leaf */ #if 0 - unsigned char name[1]; + unsigned char name[1]; #endif } structure; struct { - short int len; - short int id; - short int n_element; - short int property; - unsigned int fieldlist; - unsigned int derived; - unsigned int vshape; - unsigned short int structlen; /* numeric leaf */ + unsigned short int len; + short int id; + short int n_element; + short int property; + unsigned int fieldlist; + unsigned int derived; + unsigned int vshape; + unsigned short int structlen; /* numeric leaf */ #if 0 - unsigned char name[1]; + unsigned char name[1]; #endif } structure32; struct { - short int len; - short int id; - short int count; - short int fieldlist; - short int property; - unsigned short int un_len; /* numeric leaf */ + unsigned short int len; + short int id; + short int count; + short int fieldlist; + short int property; + unsigned short int un_len; /* numeric leaf */ #if 0 - unsigned char name[1]; + unsigned char name[1]; #endif } t_union; struct { - short int len; - short int id; - short int count; - short int property; - unsigned int fieldlist; - unsigned short int un_len; /* numeric leaf */ + unsigned short int len; + short int id; + short int count; + short int property; + unsigned int fieldlist; + unsigned short int un_len; /* numeric leaf */ #if 0 - unsigned char name[1]; + unsigned char name[1]; #endif } t_union32; struct { - short int len; - short int id; - short int count; - short int type; - short int field; - short int property; - unsigned char name[1]; + unsigned short int len; + short int id; + short int count; + short int type; + short int field; + short int property; + unsigned char name[1]; } enumeration; struct { - short int len; - short int id; - short int count; - short int property; - unsigned int type; - unsigned int field; - unsigned char name[1]; + unsigned short int len; + short int id; + short int count; + short int property; + unsigned int type; + unsigned int field; + unsigned char name[1]; } enumeration32; struct { - short int len; - short int id; - unsigned char list[1]; + unsigned short int len; + short int id; + unsigned char list[1]; } fieldlist; }; @@ -1569,7 +1569,8 @@ struct datatype *list = DEBUG_GetCVType( fieldlist ); if ( list ) - DEBUG_CopyFieldlist( dt, list ); + if(DEBUG_CopyFieldlist( dt, list ) == FALSE) + return FALSE; return DEBUG_AddCVType( typeno, dt ); } @@ -1583,7 +1584,8 @@ if ( list ) { DEBUG_SetStructSize( dt, structlen ); - DEBUG_CopyFieldlist( dt, list ); + if(DEBUG_CopyFieldlist( dt, list ) == FALSE) + return FALSE; } return DEBUG_AddCVType( typeno, dt ); Index: debugger/types.c =================================================================== RCS file: /home/wine/wine/debugger/types.c,v retrieving revision 1.24 diff -u -r1.24 types.c --- debugger/types.c 2001/04/23 18:10:32 1.24 +++ debugger/types.c 2001/12/06 18:03:16 @@ -569,8 +569,14 @@ int DEBUG_CopyFieldlist(struct datatype * dt, struct datatype * dt2) { - - assert( dt->type == dt2->type && ((dt->type == DT_STRUCT) || (dt->type == DT_ENUM))); + if (!(dt->type == dt2->type && ((dt->type == DT_STRUCT) || (dt->type == DT_ENUM)))) { + DEBUG_Printf(DBG_CHN_MESG, "Error: Copyfield list mismatch (%d<>%d): ", dt->type, dt2->type); + DEBUG_PrintTypeCast(dt); + DEBUG_Printf(DBG_CHN_MESG, " "); + DEBUG_PrintTypeCast(dt2); + DEBUG_Printf(DBG_CHN_MESG, "\n"); + return FALSE; + } if( dt->type == DT_STRUCT ) { @@ -1023,6 +1029,12 @@ DEBUG_PrintTypeCast(const struct datatype * dt) { const char* name = "none"; + + if(dt == NULL) + { + DEBUG_Printf(DBG_CHN_MESG, "--invalid--"); + return FALSE; + } if( dt->name != NULL ) {