mirror of
https://github.com/arendst/Tasmota.git
synced 2025-07-23 18:56:38 +00:00
Fix Berry Memory leak in import re
(#20823)
This commit is contained in:
parent
24b59376bb
commit
7ad95faad2
@ -29,6 +29,7 @@ All notable changes to this project will be documented in this file.
|
||||
- ESP32 PWM activity on unconfigured PWM GPIOs (#20732)
|
||||
- Shutter inverted using internal commands (#20752)
|
||||
- HASPmota PSRAM memory leak (#20818)
|
||||
- Berry Memory leak in `import re`
|
||||
|
||||
### Removed
|
||||
|
||||
|
@ -46,6 +46,9 @@ int be_re_compile(bvm *vm) {
|
||||
}
|
||||
|
||||
ByteProg *code = be_os_malloc(sizeof(ByteProg) + sz);
|
||||
if (code == NULL) {
|
||||
be_throw(vm, BE_MALLOC_FAIL); /* lack of heap space */
|
||||
}
|
||||
int ret = re1_5_compilecode(code, regex_str);
|
||||
if (ret != 0) {
|
||||
be_raise(vm, "internal_error", "error in regex");
|
||||
@ -113,11 +116,16 @@ int be_re_match_search(bvm *vm, bbool is_anchored, bbool size_only) {
|
||||
}
|
||||
|
||||
ByteProg *code = be_os_malloc(sizeof(ByteProg) + sz);
|
||||
if (code == NULL) {
|
||||
be_throw(vm, BE_MALLOC_FAIL); /* lack of heap space */
|
||||
}
|
||||
int ret = re1_5_compilecode(code, regex_str);
|
||||
if (ret != 0) {
|
||||
be_os_free(code);
|
||||
be_raise(vm, "internal_error", "error in regex");
|
||||
}
|
||||
be_re_match_search_run(vm, code, hay, is_anchored, size_only);
|
||||
be_os_free(code);
|
||||
be_return(vm);
|
||||
}
|
||||
be_raise(vm, "type_error", NULL);
|
||||
@ -138,8 +146,12 @@ int be_re_match_search_all(bvm *vm, bbool is_anchored) {
|
||||
}
|
||||
|
||||
ByteProg *code = be_os_malloc(sizeof(ByteProg) + sz);
|
||||
if (code == NULL) {
|
||||
be_throw(vm, BE_MALLOC_FAIL); /* lack of heap space */
|
||||
}
|
||||
int ret = re1_5_compilecode(code, regex_str);
|
||||
if (ret != 0) {
|
||||
be_os_free(code);
|
||||
be_raise(vm, "internal_error", "error in regex");
|
||||
}
|
||||
|
||||
@ -152,6 +164,7 @@ int be_re_match_search_all(bvm *vm, bbool is_anchored) {
|
||||
be_pop(vm, 1);
|
||||
}
|
||||
be_pop(vm, 1);
|
||||
be_os_free(code);
|
||||
be_return(vm);
|
||||
}
|
||||
be_raise(vm, "type_error", NULL);
|
||||
@ -328,11 +341,17 @@ int be_re_split(bvm *vm) {
|
||||
}
|
||||
|
||||
ByteProg *code = be_os_malloc(sizeof(ByteProg) + sz);
|
||||
if (code == NULL) {
|
||||
be_throw(vm, BE_MALLOC_FAIL); /* lack of heap space */
|
||||
}
|
||||
int ret = re1_5_compilecode(code, regex_str);
|
||||
if (ret != 0) {
|
||||
be_os_free(code);
|
||||
be_raise(vm, "internal_error", "error in regex");
|
||||
}
|
||||
return re_pattern_split_run(vm, code, hay, split_limit);
|
||||
ret = re_pattern_split_run(vm, code, hay, split_limit);
|
||||
be_os_free(code);
|
||||
return ret;
|
||||
}
|
||||
be_raise(vm, "type_error", NULL);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user