mirror of
https://github.com/janet-lang/janet
synced 2024-11-28 19:19:53 +00:00
Fix possible memory leak on buffer overflow.
(All buffer push functions can panic (longjmp), skipping deinit. Instead, we should use the garbage collected api).
This commit is contained in:
parent
4a6fcb5e23
commit
bf8d5da3dc
@ -98,43 +98,31 @@ static Janet janet_core_print(int32_t argc, Janet *argv) {
|
||||
}
|
||||
|
||||
static Janet janet_core_describe(int32_t argc, Janet *argv) {
|
||||
JanetBuffer b;
|
||||
janet_buffer_init(&b, 0);
|
||||
JanetBuffer *b = janet_buffer(0);
|
||||
for (int32_t i = 0; i < argc; ++i)
|
||||
janet_description_b(&b, argv[i]);
|
||||
Janet ret = janet_stringv(b.data, b.count);
|
||||
janet_buffer_deinit(&b);
|
||||
return ret;
|
||||
janet_description_b(b, argv[i]);
|
||||
return janet_stringv(b->data, b->count);
|
||||
}
|
||||
|
||||
static Janet janet_core_string(int32_t argc, Janet *argv) {
|
||||
JanetBuffer b;
|
||||
janet_buffer_init(&b, 0);
|
||||
JanetBuffer *b = janet_buffer(0);
|
||||
for (int32_t i = 0; i < argc; ++i)
|
||||
janet_to_string_b(&b, argv[i]);
|
||||
Janet ret = janet_stringv(b.data, b.count);
|
||||
janet_buffer_deinit(&b);
|
||||
return ret;
|
||||
janet_to_string_b(b, argv[i]);
|
||||
return janet_stringv(b->data, b->count);
|
||||
}
|
||||
|
||||
static Janet janet_core_symbol(int32_t argc, Janet *argv) {
|
||||
JanetBuffer b;
|
||||
janet_buffer_init(&b, 0);
|
||||
JanetBuffer *b = janet_buffer(0);
|
||||
for (int32_t i = 0; i < argc; ++i)
|
||||
janet_to_string_b(&b, argv[i]);
|
||||
Janet ret = janet_symbolv(b.data, b.count);
|
||||
janet_buffer_deinit(&b);
|
||||
return ret;
|
||||
janet_to_string_b(b, argv[i]);
|
||||
return janet_symbolv(b->data, b->count);
|
||||
}
|
||||
|
||||
static Janet janet_core_keyword(int32_t argc, Janet *argv) {
|
||||
JanetBuffer b;
|
||||
janet_buffer_init(&b, 0);
|
||||
JanetBuffer *b = janet_buffer(0);
|
||||
for (int32_t i = 0; i < argc; ++i)
|
||||
janet_to_string_b(&b, argv[i]);
|
||||
Janet ret = janet_keywordv(b.data, b.count);
|
||||
janet_buffer_deinit(&b);
|
||||
return ret;
|
||||
janet_to_string_b(b, argv[i]);
|
||||
return janet_keywordv(b->data, b->count);
|
||||
}
|
||||
|
||||
static Janet janet_core_buffer(int32_t argc, Janet *argv) {
|
||||
|
Loading…
Reference in New Issue
Block a user