1
0
mirror of https://github.com/janet-lang/janet synced 2025-12-12 03:28:07 +00:00

Address #1629 - janet_deinit called before threaded channel message sent

to thread.

If we take a reference to another thread inside channel code, make sure
that we increase the refcount to avoid a use after free.
This commit is contained in:
Calvin Rose
2025-09-01 10:25:02 -05:00
parent ae51434a05
commit 82416e4e4e
5 changed files with 117 additions and 9 deletions

View File

@@ -1188,6 +1188,7 @@ struct JanetAbstractType {
Janet(*call)(void *p, int32_t argc, Janet *argv);
size_t (*length)(void *p, size_t len);
JanetByteView(*bytes)(void *p, size_t len);
int (*gcperthread)(void *data, size_t len);
};
/* Some macros to let us add extra types to JanetAbstract types without
@@ -1207,7 +1208,8 @@ struct JanetAbstractType {
#define JANET_ATEND_NEXT NULL,JANET_ATEND_CALL
#define JANET_ATEND_CALL NULL,JANET_ATEND_LENGTH
#define JANET_ATEND_LENGTH NULL,JANET_ATEND_BYTES
#define JANET_ATEND_BYTES
#define JANET_ATEND_BYTES NULL,JANET_ATEND_GCPERTHREAD
#define JANET_ATEND_GCPERTHREAD
struct JanetReg {
const char *name;