Skip to content

Commit f43e03e

Browse files
committed
extmod/ure: Fix msvc warning resulting from memset on const char ** pointer
1 parent 005a7f4 commit f43e03e

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

extmod/modure.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,8 @@ STATIC mp_obj_t re_exec(bool is_anchored, uint n_args, const mp_obj_t *args) {
101101
subj.end = subj.begin + len;
102102
int caps_num = (self->re.sub + 1) * 2;
103103
mp_obj_match_t *match = m_new_obj_var(mp_obj_match_t, char*, caps_num);
104-
memset(match->caps, 0, caps_num * sizeof(char*));
104+
// cast is a workaround for a bug in msvc: it treats const char** as a const pointer instead of a pointer to pointer to const char
105+
memset((char*)match->caps, 0, caps_num * sizeof(char*));
105106
int res = re1_5_recursiveloopprog(&self->re, &subj, match->caps, caps_num, is_anchored);
106107
if (res == 0) {
107108
m_del_var(mp_obj_match_t, char*, caps_num, match);
@@ -140,7 +141,8 @@ STATIC mp_obj_t re_split(uint n_args, const mp_obj_t *args) {
140141
mp_obj_t retval = mp_obj_new_list(0, NULL);
141142
const char **caps = alloca(caps_num * sizeof(char*));
142143
while (true) {
143-
memset(caps, 0, caps_num * sizeof(char*));
144+
// cast is a workaround for a bug in msvc: it treats const char** as a const pointer instead of a pointer to pointer to const char
145+
memset((char**)caps, 0, caps_num * sizeof(char*));
144146
int res = re1_5_recursiveloopprog(&self->re, &subj, caps, caps_num, false);
145147

146148
// if we didn't have a match, or had an empty match, it's time to stop

0 commit comments

Comments
 (0)