| 11 | |
| 12 | |
| 13 | static bool next_size(const u8 **cursor, size_t *max, size_t *size) |
| 14 | { |
| 15 | size_t len; |
| 16 | varint_t varint; |
| 17 | |
| 18 | if (*max < 1) |
| 19 | return false; |
| 20 | |
| 21 | len = varint_get(*cursor, *max, &varint); |
| 22 | |
| 23 | if (len < 1) |
| 24 | return false; |
| 25 | |
| 26 | if (*max < len) { |
| 27 | *max = 0; |
| 28 | return false; |
| 29 | } |
| 30 | |
| 31 | *cursor += len; |
| 32 | *max -= len; |
| 33 | *size = varint; |
| 34 | return true; |
| 35 | } |
| 36 | |
| 37 | /* If @elements is non-NULL it must hold at least as many slots as the |
| 38 | * stack claims. A failure may have written a prefix; ignore it. */ |
no test coverage detected