[C API] allOverlappingSprites(..) method crashes on the first collision

Hi all! I'm currently working on a game using the C API, working on Windows with the latest SDK version (2.6.2). My game is entirely written in C, so it overrides the update function as outlined in the docs.

I'm trying to use the LCDSprite** playdate->sprite->allOverlappingSprites(int *len) method to check for collisions in my game, like below:

int numCollisions;
LCDSprite** allCollisions = pd->sprite->allOverlappingSprites(&numCollisions);

// Do collision handling ...

pd->system->realloc(allCollisions, 0);	

On my machine, running the above code in the simulator results in the following error being thrown when the first collision occurs:

Exception thrown: read access violation.
L was nullptr.

This happens much lower in the call stack, where L is a pointer to a lua_State object, which appears to be uninitialized:

PlaydateSimulator.exe!luaC_newobj(lua_State * L=0x0000000000000000, int tt=5, unsigned __int64 sz=56) Line 259	C

I've tried using some of the other collision checking methods and they all worked OK. There only seems to be a problem with the allOverlappingSprites(...) method, which I was hoping to use.

What am I doing wrong here? Is there some initialization step I'm missing that might cause this to happen? Any help would be much appreciated, thanks!

I don't use the sprite library with C, but I thought I would try repro this to try and help out.
If I call this function without any sprites with collision turned on then I get the same read access violation, though I seem to get it in the pd_ptrArray_removeAll(PDPtrArray *) function within cw_allOverlappingSprites(CollisionWorld *) which makes a lot more sense because I'm guessing no collision world exists if there are no colliders in it?

as soon as I add a sprite with collisions:

LCDSprite *sp = pd->sprite->newSprite();
pd->sprite->setCollisionsEnabled( sp, 1 );
pd->sprite->setCollideRect( sp, r );

Then it starts working properly.
One thing to keep in mind, its that if there are no collision the array returned is null. So you might want to guard against realloc on a null pointer.

if (allCollisions)
{
	pd->system->realloc( allCollisions, 0 );
}

If you're certain you have sprites with collision enabled then maybe try setting a breakpoint and see exactly where it's crashing for you?