Quote:
This bit of code is causing a segfault after the FF2_Logger call with this msg: Test 6
PHP Code:
cell_t AddArg(IPluginContext *pContext, Handle_t argH, void** defaultValue, FF2_ArgType aType, const char* desc)
{
FF2_Logger("Test 1");
IBasicTrie *args = GetTrie(argH);
FF2_Logger("Test 2");
Handle_t keyNamesH;
FF2_Logger("Test 3");
KeyNamesArray *keyNames;
FF2_Logger("Test 4");
if (!args->Retrieve("keyNames", (void**)keyNamesH))
return pContext->ThrowNativeError("Unable to get keyNames array!");
FF2_Logger("Test 5");
keyNames = GetKeyNamesArray(keyNamesH);
FF2_Logger("Test 6");
int arraySize = keyNames->ArraySize(); //This line right here.
FF2_Logger("Test 7");
char sSize[5];
FF2_Logger("Test 8");
smutils->Format(sSize, sizeof(sSize), "%d", arraySize);
FF2_Logger("Test 9");
Handle_t arg = InsertNewChildTrie(args, sSize);
FF2_Logger("Test 10");
if (arg == BAD_HANDLE)
{
return pContext->ThrowNativeError("Unable to insert arg%s", sSize);
}
FF2_Logger("Test 11");
IBasicTrie *argTrie = GetTrie(arg);
FF2_Logger("Test 12");
if (!argTrie->Insert("defaultValue", defaultValue))
return pContext->ThrowNativeError("Unable to add default value.");
FF2_Logger("Test 13");
if (!argTrie->Insert("type", (void**)aType))
return pContext->ThrowNativeError("Unable to add argType");
FF2_Logger("Test 14");
if (!argTrie->Insert("desc", (void**)(char*)desc))
return pContext->ThrowNativeError("Unable to add desc of: %s", desc);
FF2_Logger("Test 15");
return 1;
}
if you need full code, go here: https://github.com/WildCard65/FF2-Al.../ff2controller
Edit: Note: These files are used at the call that causes fault:
keynamesarray.h //Custom and simple class to bridge CUtlVector with a pointer.
utlvector.h //A valve header.
Edit2: More info: It crashes upon when Count is at 0, but it shouldn't.
|
Edit3: Below is part of edit2, but I left it out because it's important. Now, somehow the handle recieved apparently causes an error so it returns NULL, need to find out.
Ok, now that I see it, it is indeed attempting to call null, idk why, but it does.
Edit4: Found full issue, in the call to Retrieve of IBasicTrie, I forgot 1 little "&" symbol.