mirror of
https://github.com/pocketpy/pocketpy
synced 2026-02-04 14:40:16 +00:00
minor fix
This commit is contained in:
parent
8a019895c6
commit
8fda175c78
@ -77,8 +77,14 @@ bool c11_deserializer__check_header(c11_deserializer* self, int16_t magic, int8_
|
|||||||
return c11_deserializer__error(self, "bad header: checksum mismatch");
|
return c11_deserializer__error(self, "bad header: checksum mismatch");
|
||||||
}
|
}
|
||||||
// check version
|
// check version
|
||||||
if(self->major_ver != major_ver || self->minor_ver > minor_ver){
|
if(self->major_ver != major_ver){
|
||||||
return c11_deserializer__error(self, "bad header: version mismatch");
|
return c11_deserializer__error(self, "bad header: major version mismatch");
|
||||||
|
}
|
||||||
|
if(self->minor_ver < minor_ver){
|
||||||
|
// file_ver: 1.1, require_ver: 1.0 => ok
|
||||||
|
// file_ver: 1.1, require_ver: 1.1 => ok
|
||||||
|
// file_ver: 1.1, require_ver: 1.2 => error
|
||||||
|
return c11_deserializer__error(self, "bad header: minor version mismatch");
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,6 +1,5 @@
|
|||||||
#include "pocketpy/objects/codeobject.h"
|
#include "pocketpy/objects/codeobject.h"
|
||||||
#include "pocketpy/common/utils.h"
|
#include "pocketpy/common/utils.h"
|
||||||
#include "pocketpy/config.h"
|
|
||||||
#include "pocketpy/pocketpy.h"
|
#include "pocketpy/pocketpy.h"
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
|||||||
@ -6,6 +6,7 @@
|
|||||||
#define CODEOBJECT_MAGIC 0x434F
|
#define CODEOBJECT_MAGIC 0x434F
|
||||||
#define CODEOBJECT_VER_MAJOR 1
|
#define CODEOBJECT_VER_MAJOR 1
|
||||||
#define CODEOBJECT_VER_MINOR 0
|
#define CODEOBJECT_VER_MINOR 0
|
||||||
|
#define CODEOBJECT_VER_MINOR_MIN 0
|
||||||
|
|
||||||
// Forward declarations
|
// Forward declarations
|
||||||
static void FuncDecl__serialize(c11_serializer* s,
|
static void FuncDecl__serialize(c11_serializer* s,
|
||||||
@ -355,7 +356,7 @@ char* CodeObject__loads(const void* data, int size, CodeObject* out) {
|
|||||||
if(!c11_deserializer__check_header(&d,
|
if(!c11_deserializer__check_header(&d,
|
||||||
CODEOBJECT_MAGIC,
|
CODEOBJECT_MAGIC,
|
||||||
CODEOBJECT_VER_MAJOR,
|
CODEOBJECT_VER_MAJOR,
|
||||||
CODEOBJECT_VER_MINOR)) {
|
CODEOBJECT_VER_MINOR_MIN)) {
|
||||||
char* error_msg = c11_strdup(d.error_msg);
|
char* error_msg = c11_strdup(d.error_msg);
|
||||||
c11_deserializer__dtor(&d);
|
c11_deserializer__dtor(&d);
|
||||||
return error_msg;
|
return error_msg;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user