private void decodeTags(TagHandler handler) { int type, h, length, currentOffset; do { currentOffset = r.Offset; type = (h = r.readUI16()) >> 6; // is this a long tag header (>=63 bytes)? if (((length = h & 0x3F) == 0x3F)) { // [ed] the player treats this as a signed field and stops if it is negative. length = r.readSI32(); if (length < 0) { handler.error("negative tag length: " + length + " at offset " + currentOffset); break; } } int o = r.Offset; int eat = 0; if (type != 0) { Tag t = decodeTag(type, length); if (r.Offset - o != length) { handler.error("offset mismatch after " + Flash.Swf.TagValues.names[t.code] + ": read " + (r.Offset - o) + ", expected " + length); if (r.Offset - o < length) { eat = length - (r.Offset - o); } } handler.setOffsetAndSize(currentOffset, r.Offset - currentOffset); handler.any(t); t.visit(handler); if (eat > 0) // try to recover. (flash 8 sometimes writes nonsense, usually in fonts) { r.readFully(new byte[eat]); } } } while (type != 0); }