mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
shada: Handle all possible msgpack_unpacker_next returns
This commit is contained in:
parent
83785ef98b
commit
ebf3c86a55
@ -3106,15 +3106,38 @@ shada_read_next_item_start:
|
|||||||
msgpack_unpacked unpacked;
|
msgpack_unpacked unpacked;
|
||||||
msgpack_unpacked_init(&unpacked);
|
msgpack_unpacked_init(&unpacked);
|
||||||
|
|
||||||
|
bool did_try_to_free = false;
|
||||||
|
shada_read_next_item_read_next: {}
|
||||||
const msgpack_unpack_return result =
|
const msgpack_unpack_return result =
|
||||||
msgpack_unpacker_next(unpacker, &unpacked);
|
msgpack_unpacker_next(unpacker, &unpacked);
|
||||||
if (result != MSGPACK_UNPACK_SUCCESS) {
|
switch (result) {
|
||||||
if (result == MSGPACK_UNPACK_NOMEM_ERROR) {
|
case MSGPACK_UNPACK_SUCCESS: {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case MSGPACK_UNPACK_PARSE_ERROR: {
|
||||||
|
emsgu("Failed to parse ShaDa file due to an error at position %" PRIu64,
|
||||||
|
(uint64_t) initial_fpos);
|
||||||
|
goto shada_read_next_item_error;
|
||||||
|
}
|
||||||
|
case MSGPACK_UNPACK_NOMEM_ERROR: {
|
||||||
|
if (!did_try_to_free) {
|
||||||
|
did_try_to_free = true;
|
||||||
|
try_to_free_memory();
|
||||||
|
goto shada_read_next_item_read_next;
|
||||||
|
}
|
||||||
EMSG(e_outofmem);
|
EMSG(e_outofmem);
|
||||||
goto shada_read_next_item_error;
|
goto shada_read_next_item_error;
|
||||||
}
|
}
|
||||||
if (result == MSGPACK_UNPACK_PARSE_ERROR) {
|
case MSGPACK_UNPACK_CONTINUE: {
|
||||||
EMSG("Failed to parse ShaDa file");
|
emsgu("Failed to parse ShaDa file: incomplete msgpack string "
|
||||||
|
"at position %" PRIu64,
|
||||||
|
(uint64_t) initial_fpos);
|
||||||
|
goto shada_read_next_item_error;
|
||||||
|
}
|
||||||
|
case MSGPACK_UNPACK_EXTRA_BYTES: {
|
||||||
|
emsgu("Failed to parse ShaDa file: extra bytes in msgpack string "
|
||||||
|
"at position %" PRIu64,
|
||||||
|
(uint64_t) initial_fpos);
|
||||||
goto shada_read_next_item_error;
|
goto shada_read_next_item_error;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user