mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-01-06 07:00:59 +00:00
btstack_tlv_posix: avoid fwrite with len = 0 and ptr = NULL
This commit is contained in:
parent
eab6959f71
commit
2d3020e7ab
@ -75,9 +75,11 @@ static int btstack_tlv_posix_append_tag(btstack_tlv_posix_t * self, uint32_t tag
|
|||||||
big_endian_store_32(header, 4, data_size);
|
big_endian_store_32(header, 4, data_size);
|
||||||
size_t written_header = fwrite(header, 1, sizeof(header), self->file);
|
size_t written_header = fwrite(header, 1, sizeof(header), self->file);
|
||||||
if (written_header != sizeof(header)) return 1;
|
if (written_header != sizeof(header)) return 1;
|
||||||
size_t written_value = fwrite(data, 1, data_size, self->file);
|
if (data_size > 0) {
|
||||||
if (written_value != data_size) return 1;
|
size_t written_value = fwrite(data, 1, data_size, self->file);
|
||||||
fflush(self->file);
|
if (written_value != data_size) return 1;
|
||||||
|
}
|
||||||
|
fflush(self->file);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user