Skip to content

Conversation

@kenyonj
Copy link

@kenyonj kenyonj commented Feb 9, 2026

Summary

When connecting to Shairport Sync devices that return an empty body (Content-Length: 0) for the /auth-setup request, the rsp pointer was never assigned but was still freed at the end of the function, causing a malloc error: pointer being freed was not allocated.

The Fix

Initialize rsp to NULL and rsp_len to 0 in rtspcl_auth_setup(), so that free(rsp) is safe when no response body is received.

Testing

Tested successfully with JukeAudio whole-house audio systems running Shairport Sync 4.1.1. Before the fix, cliraop would crash immediately when trying to stream. After the fix, streaming works correctly.

Root Cause Analysis

The issue occurs in src/rtsp_client.c lines 503-504:

uint8_t* rsp;      // uninitialized
int rsp_len;       // uninitialized

When Shairport Sync returns a 200 OK with Content-Length: 0 to the auth-setup request, the exec_request function never assigns rsp (since there's no body to read). However, line 529 still calls free(rsp), which tries to free an uninitialized pointer.

When connecting to Shairport Sync devices that return an empty body
(Content-Length: 0) for the /auth-setup request, the 'rsp' pointer
was never assigned but was still freed at the end of the function,
causing a malloc error: 'pointer being freed was not allocated'.

This fix initializes 'rsp' to NULL and 'rsp_len' to 0, so that free(rsp)
is safe when no response body is received.

Fixes streaming to JukeAudio whole-house audio systems using
Shairport Sync 4.1.1.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant