|Access violation means that you're accessing memory that hasn't been allocated to your application ... so do the obvious.
Go back a few steps on the stack and look at the sequence and look at all the pointer use and check
1.) The pointer is valid
2.) Is what it pointing at allocated
3.) If it is required that the structure it points to #0 terminated ... is it.
Something in the last calls is failing one of those criteria, if need separate every pointer to a temp line of code in those sections and run a debug test on it.
In vino veritas