minor stack fixes

This commit is contained in:
CPunch 2023-05-28 12:19:52 -05:00 committed by cpunch
parent d581e68166
commit c44dc88972

View File

@ -32,6 +32,7 @@ static void initUndumpState(CState *state, UndumpState *udstate, cosmo_Reader re
static bool readBlock(UndumpState *udstate, void *data, size_t size) static bool readBlock(UndumpState *udstate, void *data, size_t size)
{ {
if (udstate->readerStatus == 0) { if (udstate->readerStatus == 0) {
/* if reader returns 1, we expect an error was thrown */
udstate->readerStatus = udstate->reader(udstate->state, data, size, udstate->userData); udstate->readerStatus = udstate->reader(udstate->state, data, size, udstate->userData);
} }
@ -73,7 +74,7 @@ static bool checkHeader(UndumpState *udstate)
uint8_t tmp; uint8_t tmp;
/* check header */ /* check header */
readBlock(udstate, magic, COSMO_MAGIC_LEN); check(readBlock(udstate, magic, COSMO_MAGIC_LEN));
if (memcmp(magic, COSMO_MAGIC, COSMO_MAGIC_LEN) != 0) { if (memcmp(magic, COSMO_MAGIC, COSMO_MAGIC_LEN) != 0) {
cosmoV_error(udstate->state, "bad header!"); cosmoV_error(udstate->state, "bad header!");
return false; return false;
@ -206,12 +207,10 @@ int cosmoD_undump(CState *state, cosmo_Reader reader, const void *userData, CObj
initUndumpState(state, &udstate, reader, userData); initUndumpState(state, &udstate, reader, userData);
if (!checkHeader(&udstate)) { if (!checkHeader(&udstate)) {
cosmoV_pushNil(state);
return 1; return 1;
} }
if (!readCObjFunction(&udstate, func)) { if (!readCObjFunction(&udstate, func)) {
cosmoV_pushNil(state);
return 1; return 1;
} }