1
0
mirror of https://github.com/janet-lang/janet synced 2025-10-31 07:33:01 +00:00

Fix memory issue in allocating decode buffer.

Since the decode table is currently a single table
per thread, we just make it a thread local to avoid
issues.
This commit is contained in:
Calvin Rose
2020-01-15 19:58:14 -06:00
parent b567ece401
commit bc2bac8cd3
2 changed files with 15 additions and 7 deletions

View File

@@ -284,7 +284,7 @@ void janet_cfuns(JanetTable *env, const char *regprefix, const JanetReg *cfuns)
while (cfuns->name[nmlen]) nmlen++;
int32_t totallen = (int32_t) prefixlen + nmlen;
if ((size_t) totallen > bufsize) {
bufsize = (size_t) (totallen) + 128;
bufsize = (size_t)(totallen) + 128;
longname_buffer = realloc(longname_buffer, bufsize);
if (NULL == longname_buffer) {
JANET_OUT_OF_MEMORY;
@@ -324,7 +324,7 @@ typedef struct {
void janet_register_abstract_type(const JanetAbstractType *at) {
JanetAbstractTypeWrap *abstract = (JanetAbstractTypeWrap *)
janet_abstract(&type_wrap, sizeof(JanetAbstractTypeWrap));
janet_abstract(&type_wrap, sizeof(JanetAbstractTypeWrap));
abstract->at = at;
Janet sym = janet_csymbolv(at->name);
if (!(janet_checktype(janet_table_get(janet_vm_registry, sym), JANET_NIL))) {