- int * positions = malloc(num*sizeof(int));
- swf_GetUsedIDs(t, positions);
- int i;
- for(i=0;i<num;i++) {
- int id = GET16(&t->data[positions[i]]);
- PyObject* obj = tagmap_id2obj(tag->tagmap, id);
- mylog(" %08x(%d) tag_getTAG: id %d is %08x\n", (int)tag, tag->ob_refcnt, id, obj);
- assert(obj!=NULL);
- TAG*othertag = tag_getRAWTAG(obj);
- int newid = tagmap_add(tagmap, obj);
- mylog(" %08x(%d) tag_getTAG: othertag->tagid=%d, new ID: %d\n", (int)tag, tag->ob_refcnt, othertag->id, newid);
-
- /* here comes the big hack- we define the *other* tags define ID.
- This assumes that the other tag is not yet written or processed,
- and we are, apart from the calling taglist, the only ones who know
- about it. */
- swf_SetDefineID(othertag, newid);
-
- PUT16(&t->data[positions[i]], newid);
+ if(num) { // tag has dependencies
+ int * positions = malloc(num*sizeof(int));
+ swf_GetUsedIDs(t, positions);
+ int i;
+ for(i=0;i<num;i++) {
+ int id = GET16(&t->data[positions[i]]);
+ PyObject* obj = tagmap_id2obj(tag->tagmap, id);
+ if(obj==NULL) {
+ PyErr_SetString(PyExc_Exception, setError("Internal error: id %d not known in taglist:"));
+ free(positions);
+ return 0;
+ }
+ int newid = tagmap_obj2id(tagmap, obj);
+ PUT16(&t->data[positions[i]], newid);
+ }
+ free(positions);