1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2025-01-17 04:52:59 +01:00

ubjson: initialize variable in error case too

For an invalid input `ubjson_get_i32()` did not return a proper error
code. Because of that `_ubjson_read_length()` could have operated on
uninitialized data.

Found via scan-build.
This commit is contained in:
René Kijewski 2015-08-24 23:59:57 +02:00
parent 11ce199c41
commit 80fe12e483

View File

@ -104,6 +104,8 @@ ssize_t ubjson_get_i32(ubjson_cookie_t *restrict cookie, ssize_t content, int32_
case UBJSON_INT32_INT32:
*dest = (int32_t) byteorder_ntohl(value.i32);
break;
default:
return -1;
}
}
return result;
@ -134,7 +136,9 @@ static ubjson_read_callback_result_t _ubjson_read_length(ubjson_cookie_t *restri
if (type == UBJSON_TYPE_INT32) {
int32_t len32;
read = ubjson_get_i32(cookie, content, &len32);
len64 = len32;
if (read > 0) {
len64 = len32;
}
}
else if (type == UBJSON_TYPE_INT64) {
read = ubjson_get_i64(cookie, content, &len64);