flex-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Guest (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (FLEX-34371) how TagEncoder handles duplicate define* tags
Date Tue, 08 Jul 2014 01:43:34 GMT

    [ https://issues.apache.org/jira/browse/FLEX-34371?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14054401#comment-14054401

Guest commented on FLEX-34371:

Here's a sample application. It defines a method writeSprite that creates a sprite containing
a editable text field, with a given initial text, placement depth, and vertical position.
When the method is called twice with the same initial text, as it is in the sample application,
it results in a SWF that reproduces the crash in this bug.

import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;

import flash.swf.Header;
import flash.swf.TagEncoder;
import flash.swf.TagHandler;
import flash.swf.TagValues;
import flash.swf.tags.DefineEditText;
import flash.swf.tags.DefineSprite;
import flash.swf.tags.PlaceObject;
import flash.swf.tags.ShowFrame;
import flash.swf.types.Matrix;
import flash.swf.types.Rect;

public class Test {

	public static void writeSprite(final TagHandler handler, final String init, final int depth,
final int y) {
		final DefineEditText et = new DefineEditText();
		et.bounds = new Rect(4000, 1000);
		et.hasText = true;
		et.varName = "val";
		et.initialText = init;

		final DefineSprite ds = new DefineSprite();

		final PlaceObject po1 = new PlaceObject(TagValues.stagPlaceObject);
		po1.depth = 1;
		po1.setMatrix(new Matrix(0, 0));

		final ShowFrame sf = new ShowFrame();


		final PlaceObject po2 = new PlaceObject(TagValues.stagPlaceObject);
		po2.depth = depth;
		po2.setMatrix(new Matrix(0, y));

	public static void main(String[] args) throws IOException {
		final TagEncoder e = new TagEncoder();

		final Header h = new Header();
		h.version = 19;
		h.size = new Rect(4000, 4000);
		h.rate = 60;

		writeSprite(e, "one", 0, 0);
		writeSprite(e, "one", 1, 1000);

		final ShowFrame sf = new ShowFrame();

		final OutputStream os = new FileOutputStream("test.swf");


Running this code generates a file test.swf. Running swfdump test.swf causes SwfxPrinter to

> how TagEncoder handles duplicate define* tags
> ---------------------------------------------
>                 Key: FLEX-34371
>                 URL: https://issues.apache.org/jira/browse/FLEX-34371
>             Project: Apache Flex
>          Issue Type: Bug
>    Affects Versions: Apache Flex 4.12.0
>            Reporter: Guest
> Suppose there are two DefineEditText tags that are the same by .equals, and a TagEncoder
handles them. This writes them both to the SWF, but assigns them the same character ID. Adobe's
Flash player can load the SWF fine, but it causes swfdump to crash with an exception like
the following:
> {code}
> Exception in thread "main" java.lang.IllegalArgumentException: symbol 154 redefined by
identical tag
>         at flash.swf.Dictionary.add(Dictionary.java:142)
>         at flash.swf.TagDecoder.decodeDefineEditText(TagDecoder.java:1160)
>         at flash.swf.TagDecoder.decodeTag(TagDecoder.java:319)
>         at flash.swf.TagDecoder.decodeTags(TagDecoder.java:194)
>         at flash.swf.TagDecoder.parse(TagDecoder.java:142)
>         at flash.swf.tools.SwfxPrinter.dumpSwf(SwfxPrinter.java:2318)
>         at flash.swf.tools.SwfxPrinter.main(SwfxPrinter.java:2225)
> {code}
> Actual result:
> defineEditText(tag) in TagEncoder calls
> {code:java}
> int id = dict.add(tag);
> {code}
> When serializing the second DefineEditText, the Dictionary finds the first one and returns
its ID. Then, the defineEditText(tag) method writes the second copy with the first one's ID.
> Expected result:
> either
> - it writes the duplicate with a new ID or
> - it does not write anything and uses the first copy's ID for references to the second.

This message was sent by Atlassian JIRA

View raw message