[flexcoders] Bug in C function caused AIR to crash

Sunday, December 25, 2011

 

I want to pass the "James" string to getTestString function, the first
time, the string could return "This is James" without any error.
Subsequently after the button is click, the application will just
hang/crash (grey out), it seem there some bugs in this code?

Screenshot: http://imagetwist.com/7896zupwtu97/a.jpg.html

Code:

FREObject getTestString(FREContext ctx, void* funcData, uint32_t argc,
FREObject argv[]) {
FREObject result;

//Temporary values to hold our actionscript code.
uint32_t albumLength;
const uint8_t *str;
uint8_t *strAll;

//Turn our actionscrpt code into native code.
FREGetObjectAsUTF8(argv[0], &albumLength, &str);
strcpy(strAll,"This is ");
strcat(strAll,str); //str is "James"

//const char *str = "this is ";
FRENewObjectFromUTF8(strlen(strAll)+1, (uint8_t *)strAll,
&result); //UTF8 to object and return

return result;
}

__._,_.___
Recent Activity:
MARKETPLACE

Stay on top of your group activity without leaving the page you're on - Get the Yahoo! Toolbar now.

.

__,_._,___

0 comments:

Post a Comment