Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions ds4_server.c
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,13 @@ static bool json_u16(const char **p, uint32_t *out) {
}

static bool json_string(const char **p, char **out) {
/* Always define *out. Every failure path below returns false without
* producing a string, and several callers reparse in place with
* `free(x); json_string(&p, &x)` (e.g. duplicate JSON keys, the "model"
* field). Without this, a non-string or malformed value leaves *out
* holding the just-freed pointer, which a later cleanup frees again --
* a double-free. Nulling on entry closes that whole class at the root. */
*out = NULL;
json_ws(p);
if (**p != '"') return false;
(*p)++;
Expand Down