`network->http->release` leaks?

Seeing this issue building against 2.7.4 on macOS. C's network->http->release seems to be leaking some memory. The example below leaks 72 bytes each time I press A. If I don't call network->http->release, it leaks a 9 and 352 byte object each time as well.

I know this is a pretty small leak for something that probably won't be happening too often, but maybe it's something I'm just missing?

#include <stdio.h>
#include <stdlib.h>

#include "pd_api.h"

PlaydateAPI *pd = NULL;

HTTPConnection *conn;

int update(void *ud);

#ifdef _WINDLL
__declspec(dllexport)
#endif
int
eventHandler(PlaydateAPI *playdate, PDSystemEvent event, uint32_t arg)
{
    (void)arg;

    if (event == kEventInit)
    {
        pd = playdate;

        pd->system->setUpdateCallback(update, NULL);

        pd->network->http->requestAccess(NULL, 0, true, NULL, NULL, NULL);
    }

    return 0;
}

int update(void *ud)
{
    PDButtons current, pushed, released;
    pd->system->getButtonState(&current, &pushed, &released);

    if (pushed & kButtonA)
    {
        if (conn != NULL)
        {
            pd->network->http->release(conn);
        }

        conn = pd->network->http->newConnection("test.com", 443, true);
    }

    return 1;
}

leaving a note here that I've filed it and put it at the top of my todo list. I'll let you know what I find!

3 Likes