Commit ba5bdbe9 authored by Howard Chu's avatar Howard Chu
Browse files

Import ITS#1570 fix from HEAD - idl_intersection overrunning array

parent 6af20d59
......@@ -913,6 +913,9 @@ idl_intersection(
if ( ID_BLOCK_ALLIDS( b ) ) {
return( idl_dup( a ) );
}
if ( ID_BLOCK_NIDS(a) == 0 || ID_BLOCK_NIDS(b) == 0 ) {
return( NULL );
}
n = idl_dup( idl_min( a, b ) );
......@@ -921,24 +924,21 @@ idl_intersection(
idl_check(b);
#endif
for ( ni = 0, ai = 0, bi = 0; ai < ID_BLOCK_NIDS(a); ai++ ) {
if ( ID_BLOCK_ID(a, ai) < ID_BLOCK_ID(b, bi) ) {
continue;
}
for ( ;
bi < ID_BLOCK_NIDS(b) && ID_BLOCK_ID(b, bi) < ID_BLOCK_ID(a, ai);
bi++ )
{
; /* NULL */
}
if ( bi == ID_BLOCK_NIDS(b) ) {
break;
}
for ( ni = 0, ai = 0, bi = 0; ; ) {
if ( ID_BLOCK_ID(b, bi) == ID_BLOCK_ID(a, ai) ) {
ID_BLOCK_ID(n, ni++) = ID_BLOCK_ID(a, ai);
bi++;
ai++;
if ( ai >= ID_BLOCK_NIDS(a) || bi >= ID_BLOCK_NIDS(b) )
break;
} else if ( ID_BLOCK_ID(a, ai) < ID_BLOCK_ID(b, bi) ) {
ai++;
if ( ai >= ID_BLOCK_NIDS(a) )
break;
} else {
bi++;
if ( bi >= ID_BLOCK_NIDS(b) )
break;
}
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment