X-Git-Url: http://git.asbjorn.biz/?a=blobdiff_plain;f=lib%2Fmodules%2Fswfaction.c;h=fb7474d130df4f1b3253380044bfd486d4cd5239;hb=275179c87d277416cfcc0d7a346ed60c4545ba31;hp=33964c1724ce0738b7045a8a83e8a09b035e0c0d;hpb=8526dcf3a698c688e2cc4430ae106b5ecf70677f;p=swftools.git diff --git a/lib/modules/swfaction.c b/lib/modules/swfaction.c index 33964c1..fb7474d 100644 --- a/lib/modules/swfaction.c +++ b/lib/modules/swfaction.c @@ -167,7 +167,7 @@ ActionTAG* swf_ActionGet(TAG*tag) length = swf_GetU16(tag); if(length) { - data = rfx_alloc(length); + data = (U8*)rfx_alloc(length); swf_GetBlock(tag, data, length); } else { data = 0; @@ -182,7 +182,6 @@ ActionTAG* swf_ActionGet(TAG*tag) void swf_ActionFree(ActionTAG*action) { if(!action) { - fprintf(stderr, "Warning: freeing zero action"); return; } action = action->parent; @@ -194,8 +193,11 @@ void swf_ActionFree(ActionTAG*action) while(action) { ActionTAG*tmp; - if(action->data && action->data != action->tmp) + if(action->data && action->data != action->tmp) { rfx_free(action->data); + action->data = 0; + } + action->len = 0; tmp = action; action=action->next; @@ -205,6 +207,9 @@ void swf_ActionFree(ActionTAG*action) void swf_ActionSet(TAG*tag, ActionTAG*action) { + if(!action) { + return; + } action=action->parent; while(action) { @@ -225,13 +230,13 @@ int OpAdvance(char c, U8*data) case 'f': return 2; case 'u': - return strlen(data)+1; + return strlen((const char*)data)+1; case 't': - return strlen(data)+1; + return strlen((const char*)data)+1; case 'l': - return strlen(data)+1; + return strlen((const char*)data)+1; case 'c': - return strlen(data)+1; + return strlen((const char*)data)+1; case 'C': return 2; case 's': @@ -245,7 +250,7 @@ int OpAdvance(char c, U8*data) case 'p': { U8 type = *data++; if(type == 0) { - return 1+strlen(data)+1; //string + return 1+strlen((const char*)data)+1; //string } else if (type == 1) { return 1+4; //float } else if (type == 2) { @@ -349,7 +354,7 @@ void swf_DumpActions(ActionTAG*atag, char*prefix) printf(" String:\"%s\"", data); #ifdef MAX_LOOKUP if (entrylen - replacelen + newlen); + int newlen = strlen((const char *)replacement); + char * newdata = (char*)rfx_alloc(atag->len - replacelen + newlen); int rpos = replacepos - atag->data; memcpy(newdata, atag->data, rpos); memcpy(&newdata[rpos], replacement, newlen); memcpy(&newdata[rpos+newlen], &replacepos[replacelen], &data[atag->len] - &replacepos[replacelen]); rfx_free(atag->data); - atag->data = newdata; + atag->data = (U8*)newdata; data = &atag->data[rpos+newlen+1]; } } @@ -680,10 +685,11 @@ ActionTAG* swf_AddActionTAG(ActionTAG*atag, U8 op, U8*data, U16 len) tmp->prev = 0; tmp->parent = tmp; } - if(data || !len) + if(data || !len) { tmp->data = data; - else + } else { tmp->data = tmp->tmp; + } tmp->len = len; tmp->op = op; @@ -965,7 +971,7 @@ ActionTAG* action_WaitForFrame(ActionTAG*atag, U16 frame, U8 skip) *(U8*)&atag->tmp[2] = skip; return atag; } -ActionTAG* action_SetTarget(ActionTAG*atag, char* target) +ActionTAG* action_SetTarget(ActionTAG*atag, const char* target) { char*ptr = strdup(target); return swf_AddActionTAG(atag, ACTION_SETTARGET, (U8*)ptr, strlen(ptr)+1); @@ -1007,11 +1013,11 @@ ActionTAG* action_PushLookup16(ActionTAG*atag, U16 index) { atag = swf_AddActionTAG(atag, ACTION_PUSH, 0, 3); *(U8*)atag->tmp = 9; //lookup - *(U8*)&atag->tmp[1] = index; + *(U8*)&atag->tmp[1] = (U8)index; *(U8*)&atag->tmp[2] = index>>8; return atag; } -ActionTAG* action_PushString(ActionTAG*atag, char*str) +ActionTAG* action_PushString(ActionTAG*atag, const char*str) { int l = strlen(str); char*ptr = (char*)rfx_alloc(l+2); @@ -1051,7 +1057,7 @@ ActionTAG* action_PushDouble(ActionTAG*atag, double d) ActionTAG* action_PushInt(ActionTAG*atag, int i) { atag = swf_AddActionTAG(atag, ACTION_PUSH, 0, 5); - *(U8*)atag->tmp = 7; //int + atag->tmp[0] = 7; //int atag->tmp[1] = i; atag->tmp[2] = i>>8; atag->tmp[3] = i>>16; @@ -1063,14 +1069,14 @@ ActionTAG* action_GotoLabel(ActionTAG*atag, char* label) char*ptr = strdup(label); return swf_AddActionTAG(atag, ACTION_GOTOLABEL, (U8*)ptr, strlen(ptr)); } -ActionTAG* action_GetUrl(ActionTAG*atag, char* url, char* label) +ActionTAG* action_GetUrl(ActionTAG*atag, const char* url, char* label) { int l1= strlen(url); int l2= strlen(label); - char*ptr = rfx_alloc(l1+l2+2); + char*ptr = (char*)rfx_alloc(l1+l2+2); strcpy(ptr, url); strcpy(&ptr[l1+1], label); - return swf_AddActionTAG(atag, ACTION_GETURL, ptr, l1+l2+2); + return swf_AddActionTAG(atag, ACTION_GETURL, (U8*)ptr, l1+l2+2); } //TODO: ActionTAG* action_DefineFunction(ActionTAG*atag, U8*data, int len) {return atag;} @@ -1092,13 +1098,13 @@ ActionTAG* swf_ActionCompile(const char* source, int version) if(!ret || buffer==0 || len == 0) return 0; - swf_SetBlock(tag, buffer, len); + swf_SetBlock(tag, (U8*)buffer, len); swf_SetU8(tag, 0); rfx_free(buffer); a = swf_ActionGet(tag); - swf_DeleteTag(tag); + swf_DeleteTag(0, tag); return a; }