Have you tried to check if your handles are the same in both places?

Just to make sure that it's not a stack problem, try allocating and then freeing the "mystruct" data instead.

--
Mats