Skip to content

Commit

Permalink
fix malformed json for empty row {0} to "{0}0"
Browse files Browse the repository at this point in the history
  • Loading branch information
atlanticn committed Aug 4, 2023
1 parent bdd7933 commit 1f22415
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/decoder_util.c
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,11 @@ static char *bitrow_asprint_code(uint8_t const *bitrow, unsigned bit_len)
}
// remove last nibble if needed
row_bytes[2 * (bit_len + 3) / 8] = '\0';

Check failure on line 58 in src/decoder_util.c

View workflow job for this annotation

GitHub Actions / Check code style

TRAILING whitespace error
// print at least one '0'
if (bit_len == 0) {
sprintf(row_bytes, "0");
}

// a simple bitrow representation
row_code = malloc(8 + bit_len / 4 + 1); // "{nnnn}..\0"
Expand Down
5 changes: 5 additions & 0 deletions src/devices/flex.c
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,11 @@ static int flex_callback(r_device *decoder, bitbuffer_t *bitbuffer)
// add a data line for each getter
render_getters(row_data[i], bitbuffer->bb[i], params);

// print at least one '0'
if (row_bytes[0] == '\0') {
sprintf(row_bytes, "0");
}

Check failure on line 324 in src/devices/flex.c

View workflow job for this annotation

GitHub Actions / Check code style

TRAILING whitespace error
// a simpler representation for csv output
row_codes[i] = malloc(8 + bitbuffer->bits_per_row[i] / 4 + 1); // "{nnnn}..\0"
if (!row_codes[i])
Expand Down

0 comments on commit 1f22415

Please sign in to comment.