X-Git-Url: http://git.asbjorn.biz/?a=blobdiff_plain;f=lib%2Fas3%2Fpool.c;h=913a84e189ccdc8712d6a8f2c0f3f1a910bb39ed;hb=3dea7306ae2c9590673c10dec1fbabcd6d7e1806;hp=67615378e7a2b371df32e3afd101c7db0245d730;hpb=bb864e1a88e670c99d559c7dee4f74e9bf7d978b;p=swftools.git diff --git a/lib/as3/pool.c b/lib/as3/pool.c index 6761537..913a84e 100644 --- a/lib/as3/pool.c +++ b/lib/as3/pool.c @@ -634,9 +634,6 @@ type_t multiname_type = { // ------------------------------- constants ------------------------------------- -#define NS_TYPE(x) ((x) == 0x08 || (x) == 0x16 || (x) == 0x17 || (x) == 0x18 || \ - (x) == 0x19 || (x) == 0x1a || (x) == 0x05) - #define UNIQUE_CONSTANT(x) ((x) == CONSTANT_TRUE || (x) == CONSTANT_FALSE || (x) == CONSTANT_NULL || (x) == CONSTANT_UNDEFINED) constant_t* constant_new_int(int i) @@ -706,6 +703,18 @@ constant_t* constant_new_undefined() c->type = CONSTANT_UNDEFINED; return c; } +constant_t* constant_clone(constant_t*other) +{ + if(!other) return 0; + constant_t*c = malloc(sizeof(constant_t)); + memcpy(c, other, sizeof(constant_t)); + if(NS_TYPE(c->type)) { + c->ns = namespace_clone(other->ns); + } else if(c->type == CONSTANT_STRING) { + c->s = string_dup3(other->s); + } + return c; +} constant_t* constant_fromindex(pool_t*pool, int index, int type) { if(!index) { @@ -791,6 +800,10 @@ int constant_get_index(pool_t*pool, constant_t*c) return pool_register_float(pool, c->f); } else if(c->type == CONSTANT_STRING) { return pool_register_string2(pool, c->s); + } else if(c->type == CONSTANT_UNDEFINED) { + /* write undefined with index 0 (and no type). Otherwise, the FlashPlayer + seems to throw an "attempt to read out of bounds" exception */ + return 0; } else if(!constant_has_index(c)) { return 1; } else {