Skip to content

Commit 58902e3

Browse files
committed
Zero output parameters when BbGet*() fails
1 parent 84f3763 commit 58902e3

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/ByteBuffer.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ void BbRewindBuffer(PBYTE_BUFFER buff) {
5555
// Get a variable number of bytes from the byte buffer (all or nothing though)
5656
bool BbGetBytes(PBYTE_BUFFER buff, uint8_t* data, int length) {
5757
if (buff->position + length > buff->length) {
58+
memset(data, 0, length);
5859
return false;
5960
}
6061

@@ -72,6 +73,7 @@ bool BbGet8(PBYTE_BUFFER buff, uint8_t* c) {
7273
// Get a short from the byte buffer
7374
bool BbGet16(PBYTE_BUFFER buff, uint16_t* s) {
7475
if (buff->position + sizeof(*s) > buff->length) {
76+
*s = 0;
7577
return false;
7678
}
7779

@@ -86,6 +88,7 @@ bool BbGet16(PBYTE_BUFFER buff, uint16_t* s) {
8688
// Get an int from the byte buffer
8789
bool BbGet32(PBYTE_BUFFER buff, uint32_t* i) {
8890
if (buff->position + sizeof(*i) > buff->length) {
91+
*i = 0;
8992
return false;
9093
}
9194

@@ -100,6 +103,7 @@ bool BbGet32(PBYTE_BUFFER buff, uint32_t* i) {
100103
// Get a long from the byte buffer
101104
bool BbGet64(PBYTE_BUFFER buff, uint64_t* l) {
102105
if (buff->position + sizeof(*l) > buff->length) {
106+
*l = 0;
103107
return false;
104108
}
105109

0 commit comments

Comments
 (0)