Browse Source

change DUK_MEMSET() to DUK_MEMZERO() when appropriate

pull/2/head
Sami Vaarala 11 years ago
parent
commit
5475a07a4f
  1. 16
      src/duk_bi_date.c
  2. 6
      src/duk_bi_json.c
  3. 2
      src/duk_debug.h
  4. 2
      src/duk_debug_heap.c
  5. 4
      src/duk_debug_macros.c
  6. 8
      src/duk_debug_vsnprintf.c
  7. 10
      src/duk_hbuffer_ops.c
  8. 6
      src/duk_heap_alloc.c
  9. 4
      src/duk_heap_memory.c
  10. 4
      src/duk_heap_stringtable.c
  11. 8
      src/duk_hobject_alloc.c
  12. 4
      src/duk_hobject_pc2line.c
  13. 6
      src/duk_hthread_alloc.c
  14. 2
      src/duk_hthread_builtins.c
  15. 10
      src/duk_js_compiler.c
  16. 4
      src/duk_lexer.c
  17. 12
      src/duk_numconv.c
  18. 2
      src/duk_regexp_compiler.c
  19. 4
      src/duk_regexp_executor.c
  20. 4
      src/duk_unicode_support.c

16
src/duk_bi_date.c

@ -132,7 +132,7 @@ static void duk__convert_systime_to_ularge(const SYSTEMTIME *st, ULARGE_INTEGER
}
}
static void duk__set_systime_jan1970(SYSTEMTIME *st) {
DUK_MEMSET((void *) st, 0, sizeof(*st));
DUK_MEMZERO((void *) st, sizeof(*st));
st->wYear = 1970;
st->wMonth = 1;
st->wDayOfWeek = 4; /* not sure whether or not needed; Thursday */
@ -220,7 +220,7 @@ static int duk__get_local_tzoffset(double d) {
t1 = t;
DUK_MEMSET((void *) tms, 0, sizeof(struct tm) * 2);
DUK_MEMZERO((void *) tms, sizeof(struct tm) * 2);
#if defined(DUK_USE_DATE_TZO_GMTIME_R)
(void) gmtime_r(&t, &tms[0]);
@ -318,13 +318,13 @@ static int duk__parse_string_strptime(duk_context *ctx, const char *str) {
/* copy to buffer with spare to avoid Valgrind gripes from strptime */
DUK_ASSERT(str != NULL);
DUK_MEMSET(buf, 0, sizeof(buf)); /* valgrind whine without this */
DUK_MEMZERO(buf, sizeof(buf)); /* valgrind whine without this */
DUK_SNPRINTF(buf, sizeof(buf), "%s", str);
buf[sizeof(buf) - 1] = (char) 0;
DUK_DDDPRINT("parsing: '%s'", buf);
DUK_MEMSET(&tm, 0, sizeof(tm));
DUK_MEMZERO(&tm, sizeof(tm));
if (strptime((const char *) buf, "%c", &tm) != NULL) {
DUK_DDDPRINT("before mktime: tm={sec:%d,min:%d,hour:%d,mday:%d,mon:%d,year:%d,"
"wday:%d,yday:%d,isdst:%d}",
@ -355,7 +355,7 @@ static int duk__parse_string_getdate(duk_context *ctx, const char *str) {
* convenient for an embeddable interpreter.
*/
DUK_MEMSET(&tm, 0, sizeof(struct tm));
DUK_MEMZERO(&tm, sizeof(struct tm));
rc = getdate_r(str, &tm);
DUK_DDDPRINT("getdate_r() -> %d", rc);
@ -394,7 +394,7 @@ static int duk__format_parts_strftime(duk_context *ctx, int *parts, int tzoffset
return 0;
}
DUK_MEMSET(&tm, 0, sizeof(tm));
DUK_MEMZERO(&tm, sizeof(tm));
tm.tm_sec = parts[DUK__IDX_SECOND];
tm.tm_min = parts[DUK__IDX_MINUTE];
tm.tm_hour = parts[DUK__IDX_HOUR];
@ -404,7 +404,7 @@ static int duk__format_parts_strftime(duk_context *ctx, int *parts, int tzoffset
tm.tm_wday = parts[DUK__IDX_WEEKDAY];
tm.tm_isdst = 0;
DUK_MEMSET(buf, 0, sizeof(buf));
DUK_MEMZERO(buf, sizeof(buf));
if ((flags & DUK__FLAG_TOSTRING_DATE) && (flags & DUK__FLAG_TOSTRING_TIME)) {
fmt = "%c";
} else if (flags & DUK__FLAG_TOSTRING_DATE) {
@ -527,7 +527,7 @@ static int duk__parse_string_iso8601_subset(duk_context *ctx, const char *str) {
int i;
/* During parsing, month and day are one-based; set defaults here. */
DUK_MEMSET(parts, 0, sizeof(parts));
DUK_MEMZERO(parts, sizeof(parts));
DUK_ASSERT(parts[DUK__IDX_YEAR] == 0); /* don't care value, year is mandatory */
parts[DUK__IDX_MONTH] = 1;
parts[DUK__IDX_DAY] = 1;

6
src/duk_bi_json.c

@ -1432,7 +1432,7 @@ static void duk__enc_value2(duk_json_enc_ctx *js_ctx) {
const char *fmt;
void *ptr = DUK_TVAL_GET_POINTER(tv);
DUK_MEMSET(buf, 0, sizeof(buf));
DUK_MEMZERO(buf, sizeof(buf));
/* The #ifdef clutter here needs to handle the three cases:
* (1) JSONX+JSONC, (2) JSONX only, (3) JSONC only.
@ -1624,7 +1624,7 @@ void duk_bi_json_parse_helper(duk_context *ctx,
duk_get_tval(ctx, idx_value), duk_get_tval(ctx, idx_reviver),
flags, duk_get_top(ctx));
DUK_MEMSET(&js_ctx_alloc, 0, sizeof(js_ctx_alloc));
DUK_MEMZERO(&js_ctx_alloc, sizeof(js_ctx_alloc));
js_ctx->thr = thr;
#ifdef DUK_USE_EXPLICIT_NULL_INIT
/* nothing now */
@ -1712,7 +1712,7 @@ void duk_bi_json_stringify_helper(duk_context *ctx,
* Context init
*/
DUK_MEMSET(&js_ctx_alloc, 0, sizeof(js_ctx_alloc));
DUK_MEMZERO(&js_ctx_alloc, sizeof(js_ctx_alloc));
js_ctx->thr = thr;
#ifdef DUK_USE_EXPLICIT_NULL_INIT
js_ctx->h_replacer = NULL;

2
src/duk_debug.h

@ -88,7 +88,7 @@
/* summary macros */
#define DUK_DEBUG_SUMMARY_INIT() do { \
DUK_MEMSET(duk_debug_summary_buf, 0, sizeof(duk_debug_summary_buf)); \
DUK_MEMZERO(duk_debug_summary_buf, sizeof(duk_debug_summary_buf)); \
duk_debug_summary_idx = 0; \
} while (0)

2
src/duk_debug_heap.c

@ -12,7 +12,7 @@ static void duk__sanitize_snippet(char *buf, duk_size_t buf_size, duk_hstring *s
duk_size_t maxchars;
duk_uint8_t *data;
DUK_MEMSET(buf, 0, buf_size);
DUK_MEMZERO(buf, buf_size);
maxchars = (duk_size_t) (buf_size - 1);
data = DUK_HSTRING_GET_DATA(str);

4
src/duk_debug_macros.c

@ -87,7 +87,7 @@ void duk_debug_log(int level, const char *file, int line, const char *func, char
va_start(ap, fmt);
DUK_MEMSET((void *) duk__debug_buf, 0, (size_t) DUK__DEBUG_BUFSIZE);
DUK_MEMZERO((void *) duk__debug_buf, (size_t) DUK__DEBUG_BUFSIZE);
duk_debug_vsnprintf(duk__debug_buf, DUK__DEBUG_BUFSIZE - 1, fmt, ap);
#ifdef DUK_USE_DPRINT_RDTSC
@ -130,7 +130,7 @@ void duk_debug_log(char *fmt, ...) {
va_start(ap, fmt);
DUK_MEMSET((void *) duk__debug_buf, 0, (size_t) DUK__DEBUG_BUFSIZE);
DUK_MEMZERO((void *) duk__debug_buf, (size_t) DUK__DEBUG_BUFSIZE);
duk_debug_vsnprintf(duk__debug_buf, DUK__DEBUG_BUFSIZE - 1, fmt, ap);
#ifdef DUK_USE_DPRINT_RDTSC

8
src/duk_debug_vsnprintf.c

@ -767,7 +767,7 @@ int duk_debug_vsnprintf(char *str, size_t size, const char *format, va_list ap)
const char *p_end = p + strlen(format);
int retval;
DUK_MEMSET(&fb, 0, sizeof(fb));
DUK_MEMZERO(&fb, sizeof(fb));
fb.buffer = (duk_uint8_t *) str;
fb.length = size;
fb.offset = 0;
@ -791,7 +791,7 @@ int duk_debug_vsnprintf(char *str, size_t size, const char *format, va_list ap)
* understand. See man 3 printf.
*/
DUK_MEMSET(&st, 0, sizeof(st));
DUK_MEMZERO(&st, sizeof(st));
st.fb = &fb;
st.depth = 0;
st.depth_limit = 1;
@ -856,7 +856,7 @@ int duk_debug_vsnprintf(char *str, size_t size, const char *format, va_list ap)
/* format is too large, abort */
goto error;
}
DUK_MEMSET(fmtbuf, 0, sizeof(fmtbuf));
DUK_MEMZERO(fmtbuf, sizeof(fmtbuf));
DUK_MEMCPY(fmtbuf, p_begfmt, fmtlen);
/* assume exactly 1 arg, which is why '*' is forbidden; arg size still
@ -914,7 +914,7 @@ void duk_debug_format_funcptr(char *buf, int buf_size, unsigned char *fptr, int
char *p = buf;
char *p_end = buf + buf_size - 1;
DUK_MEMSET(buf, 0, buf_size);
DUK_MEMZERO(buf, buf_size);
for (i = 0; i < fptr_size; i++) {
int left = p_end - p;

10
src/duk_hbuffer_ops.c

@ -73,9 +73,8 @@ void duk_hbuffer_resize(duk_hthread *thr, duk_hbuffer_dynamic *buf, size_t new_s
* be rezeroed (the safety NUL byte).
*/
DUK_ASSERT(new_alloc_size - buf->usable_size > 0);
DUK_MEMSET((void *) ((char *) res + buf->usable_size),
0,
new_alloc_size - buf->usable_size);
DUK_MEMZERO((void *) ((char *) res + buf->usable_size),
new_alloc_size - buf->usable_size);
}
buf->size = new_size;
@ -391,9 +390,8 @@ void duk_hbuffer_remove_slice(duk_hthread *thr, duk_hbuffer_dynamic *buf, size_t
DUK_HBUFFER_GET_SIZE(buf) - end_offset); /* always > 0 */
}
DUK_MEMSET(p + DUK_HBUFFER_GET_SIZE(buf) - length,
0,
length); /* always > 0 */
DUK_MEMZERO(p + DUK_HBUFFER_GET_SIZE(buf) - length,
length); /* always > 0 */
buf->size -= length;

6
src/duk_heap_alloc.c

@ -259,7 +259,7 @@ static int duk__init_heap_strings(duk_heap *heap) {
duk_bitdecoder_ctx *bd = &bd_ctx; /* convenience */
int i, j;
DUK_MEMSET(&bd_ctx, 0, sizeof(bd_ctx));
DUK_MEMZERO(&bd_ctx, sizeof(bd_ctx));
bd->data = (const duk_uint8_t *) duk_strings_data;
bd->length = (duk_size_t) DUK_STRDATA_DATA_LENGTH;
@ -513,7 +513,7 @@ duk_heap *duk_heap_alloc(duk_alloc_function alloc_func,
}
/* zero everything */
DUK_MEMSET(res, 0, sizeof(*res));
DUK_MEMZERO(res, sizeof(*res));
/* explicit NULL inits */
#ifdef DUK_USE_EXPLICIT_NULL_INIT
@ -590,7 +590,7 @@ duk_heap *duk_heap_alloc(duk_alloc_function alloc_func,
}
}
#else
DUK_MEMSET(res->st, 0, sizeof(duk_hstring *) * DUK_STRTAB_INITIAL_SIZE);
DUK_MEMZERO(res->st, sizeof(duk_hstring *) * DUK_STRTAB_INITIAL_SIZE);
#endif
/* strcache init */

4
src/duk_heap_memory.c

@ -141,7 +141,7 @@ void *duk_heap_mem_alloc_zeroed(duk_heap *heap, size_t size) {
res = DUK_ALLOC(heap, size);
if (res) {
/* assume memset with zero size is OK */
DUK_MEMSET(res, 0, size);
DUK_MEMZERO(res, size);
}
return res;
}
@ -426,7 +426,7 @@ void *duk_heap_mem_alloc_checked_zeroed(duk_hthread *thr, size_t size) {
#endif
}
/* assume memset with zero size is OK */
DUK_MEMSET(res, 0, size);
DUK_MEMZERO(res, size);
return res;
}

4
src/duk_heap_stringtable.c

@ -34,7 +34,7 @@ static duk_hstring *duk__alloc_init_hstring(duk_heap *heap,
goto error;
}
DUK_MEMSET(res, 0, sizeof(duk_hstring));
DUK_MEMZERO(res, sizeof(duk_hstring));
#ifdef DUK_USE_EXPLICIT_NULL_INIT
DUK_HEAPHDR_STRING_INIT_NULLS(&res->hdr);
#endif
@ -239,7 +239,7 @@ static int duk__resize_strtab_raw(duk_heap *heap, duk_uint32_t new_size) {
new_entries[i] = NULL;
}
#else
DUK_MEMSET(new_entries, 0, sizeof(duk_hstring *) * new_size);
DUK_MEMZERO(new_entries, sizeof(duk_hstring *) * new_size);
#endif
/* Because new_size > duk__count_used(heap), guaranteed to work */

8
src/duk_hobject_alloc.c

@ -52,7 +52,7 @@ duk_hobject *duk_hobject_alloc(duk_heap *heap, int hobject_flags) {
if (!res) {
return NULL;
}
DUK_MEMSET(res, 0, sizeof(duk_hobject));
DUK_MEMZERO(res, sizeof(duk_hobject));
duk__init_object_parts(heap, res, hobject_flags);
@ -66,7 +66,7 @@ duk_hcompiledfunction *duk_hcompiledfunction_alloc(duk_heap *heap, int hobject_f
if (!res) {
return NULL;
}
DUK_MEMSET(res, 0, sizeof(duk_hcompiledfunction));
DUK_MEMZERO(res, sizeof(duk_hcompiledfunction));
duk__init_object_parts(heap, &res->obj, hobject_flags);
@ -86,7 +86,7 @@ duk_hnativefunction *duk_hnativefunction_alloc(duk_heap *heap, int hobject_flags
if (!res) {
return NULL;
}
DUK_MEMSET(res, 0, sizeof(duk_hnativefunction));
DUK_MEMZERO(res, sizeof(duk_hnativefunction));
duk__init_object_parts(heap, &res->obj, hobject_flags);
@ -112,7 +112,7 @@ duk_hthread *duk_hthread_alloc(duk_heap *heap, int hobject_flags) {
if (!res) {
return NULL;
}
DUK_MEMSET(res, 0, sizeof(duk_hthread));
DUK_MEMZERO(res, sizeof(duk_hthread));
duk__init_object_parts(heap, &res->obj, hobject_flags);

4
src/duk_hobject_pc2line.c

@ -62,7 +62,7 @@ void duk_hobject_pc2line_pack(duk_hthread *thr, duk_compiler_instr *instrs, duk_
(int) hdr[hdr_index + 1]);
#endif
DUK_MEMSET(be_ctx, 0, sizeof(*be_ctx));
DUK_MEMZERO(be_ctx, sizeof(*be_ctx));
be_ctx->data = ((duk_uint8_t *) hdr) + curr_offset;
be_ctx->length = (duk_size_t) DUK_PC2LINE_MAX_DIFF_LENGTH;
@ -164,7 +164,7 @@ duk_uint_fast32_t duk_hobject_pc2line_query(duk_hbuffer_fixed *buf, duk_uint_fas
goto error;
}
DUK_MEMSET(bd_ctx, 0, sizeof(*bd_ctx));
DUK_MEMZERO(bd_ctx, sizeof(*bd_ctx));
bd_ctx->data = ((duk_uint8_t *) hdr) + start_offset;
bd_ctx->length = (duk_size_t) (DUK_HBUFFER_FIXED_GET_SIZE(buf) - start_offset);

6
src/duk_hthread_alloc.c

@ -29,7 +29,7 @@ int duk_hthread_init_stacks(duk_heap *heap, duk_hthread *thr) {
if (!thr->valstack) {
goto fail;
}
DUK_MEMSET(thr->valstack, 0, alloc_size);
DUK_MEMZERO(thr->valstack, alloc_size);
thr->valstack_end = thr->valstack + DUK_VALSTACK_INITIAL_SIZE;
thr->valstack_bottom = thr->valstack;
thr->valstack_top = thr->valstack;
@ -44,7 +44,7 @@ int duk_hthread_init_stacks(duk_heap *heap, duk_hthread *thr) {
if (!thr->callstack) {
goto fail;
}
DUK_MEMSET(thr->callstack, 0, alloc_size);
DUK_MEMZERO(thr->callstack, alloc_size);
thr->callstack_size = DUK_CALLSTACK_INITIAL_SIZE;
DUK_ASSERT(thr->callstack_top == 0);
@ -54,7 +54,7 @@ int duk_hthread_init_stacks(duk_heap *heap, duk_hthread *thr) {
if (!thr->catchstack) {
goto fail;
}
DUK_MEMSET(thr->catchstack, 0, alloc_size);
DUK_MEMZERO(thr->catchstack, alloc_size);
thr->catchstack_size = DUK_CATCHSTACK_INITIAL_SIZE;
DUK_ASSERT(thr->catchstack_top == 0);

2
src/duk_hthread_builtins.c

@ -52,7 +52,7 @@ void duk_hthread_create_builtin_objects(duk_hthread *thr) {
DUK_DPRINT("INITBUILTINS BEGIN");
DUK_MEMSET(&bd_ctx, 0, sizeof(bd_ctx));
DUK_MEMZERO(&bd_ctx, sizeof(bd_ctx));
bd->data = (const duk_uint8_t *) duk_builtins_data;
bd->length = (duk_size_t) DUK_BUILTINS_DATA_LENGTH;

10
src/duk_js_compiler.c

@ -480,7 +480,7 @@ static void duk__init_func_valstack_slots(duk_compiler_ctx *comp_ctx) {
entry_top = duk_get_top(ctx);
DUK_MEMSET(func, 0, sizeof(*func)); /* intentional overlap with earlier memzero */
DUK_MEMZERO(func, sizeof(*func)); /* intentional overlap with earlier memzero */
#ifdef DUK_USE_EXPLICIT_NULL_INIT
func->h_name = NULL;
func->h_code = NULL;
@ -3902,7 +3902,7 @@ static void duk__expr(duk_compiler_ctx *comp_ctx, duk_ivalue *res, int rbp_flags
DUK_DDDPRINT("duk__expr(), rbp_flags=%d, rbp=%d, allow_in=%d, paren_level=%d",
rbp_flags, rbp, comp_ctx->curr_func.allow_in, comp_ctx->curr_func.paren_level);
DUK_MEMSET(&tmp_alloc, 0, sizeof(tmp_alloc));
DUK_MEMZERO(&tmp_alloc, sizeof(tmp_alloc));
tmp->x1.valstack_idx = duk_get_top(ctx);
tmp->x2.valstack_idx = tmp->x1.valstack_idx + 1;
duk_push_undefined(ctx);
@ -5695,7 +5695,7 @@ static void duk__parse_stmts(duk_compiler_ctx *comp_ctx, int allow_source_elem,
* for nested functions (which may occur inside expressions).
*/
DUK_MEMSET(&res_alloc, 0, sizeof(res_alloc));
DUK_MEMZERO(&res_alloc, sizeof(res_alloc));
res->t = DUK_IVAL_PLAIN;
res->x1.t = DUK_ISPEC_VALUE;
res->x1.valstack_idx = duk_get_top(ctx);
@ -6489,7 +6489,7 @@ static int duk__parse_func_like_fnum(duk_compiler_ctx *comp_ctx, int is_decl, in
DUK_MEMCPY(&old_func, &comp_ctx->curr_func, sizeof(duk_compiler_func));
DUK_MEMSET(&comp_ctx->curr_func, 0, sizeof(duk_compiler_func));
DUK_MEMZERO(&comp_ctx->curr_func, sizeof(duk_compiler_func));
duk__init_func_valstack_slots(comp_ctx);
DUK_ASSERT(comp_ctx->curr_func.num_formals == 0);
@ -6717,7 +6717,7 @@ void duk_js_compile(duk_hthread *thr, int flags) {
* Alternatives would be nice.
*/
DUK_MEMSET(&comp_stk, 0, sizeof(comp_stk));
DUK_MEMZERO(&comp_stk, sizeof(comp_stk));
comp_stk.flags = flags;
duk_push_pointer(ctx, (void *) &comp_stk);

4
src/duk_lexer.c

@ -362,7 +362,7 @@ static void duk__internbuffer(duk_lexer_ctx *lex_ctx, int valstack_idx) {
void duk_lexer_initctx(duk_lexer_ctx *lex_ctx) {
DUK_ASSERT(lex_ctx != NULL);
DUK_MEMSET(lex_ctx, 0, sizeof(*lex_ctx));
DUK_MEMZERO(lex_ctx, sizeof(*lex_ctx));
#ifdef DUK_USE_EXPLICIT_NULL_INIT
lex_ctx->thr = NULL;
lex_ctx->input = NULL;
@ -1334,7 +1334,7 @@ void duk_lexer_parse_re_token(duk_lexer_ctx *lex_ctx, duk_re_token *out_token) {
return; /* unreachable */
}
DUK_MEMSET(out_token, 0, sizeof(*out_token));
DUK_MEMZERO(out_token, sizeof(*out_token));
x = DUK__L0();
y = DUK__L1();

12
src/duk_numconv.c

@ -412,7 +412,7 @@ static void duk__bi_mul(duk__bigint *x, duk__bigint *y, duk__bigint *z) {
return;
}
DUK_MEMSET((void *) x->v, 0, (size_t) (sizeof(duk_uint32_t) * nx));
DUK_MEMZERO((void *) x->v, (size_t) (sizeof(duk_uint32_t) * nx));
x->n = nx;
nz = z->n;
@ -562,7 +562,7 @@ static void duk__bi_twoexp(duk__bigint *x, duk_small_int_t y) {
n = (y / 32) + 1;
DUK_ASSERT(n > 0);
r = y % 32;
DUK_MEMSET((void *) x->v, 0, sizeof(duk_uint32_t) * n);
DUK_MEMZERO((void *) x->v, sizeof(duk_uint32_t) * n);
x->n = n;
x->v[n - 1] = (((duk_uint32_t) 1) << r);
}
@ -1101,7 +1101,7 @@ static void duk__dragon4_generate(duk__numconv_stringify_ctx *nc_ctx) {
{
duk_uint8_t buf[2048];
duk_small_int_t i, t;
DUK_MEMSET(buf, 0, sizeof(buf));
DUK_MEMZERO(buf, sizeof(buf));
for (i = 0; i < nc_ctx->count; i++) {
t = nc_ctx->digits[i];
if (t < 0 || t > 36) {
@ -1406,7 +1406,7 @@ void duk__dragon4_ctx_to_double(duk__numconv_stringify_ctx *nc_ctx, duk_double_t
* (perhaps because the low part is set (seemingly) conditionally in a
* loop), so this is here to avoid the bogus warning.
*/
DUK_MEMSET((void *) &u, 0, sizeof(u));
DUK_MEMZERO((void *) &u, sizeof(u));
/*
* Figure out how generated digits match up with the mantissa,
@ -1621,7 +1621,7 @@ void duk_numconv_stringify(duk_context *ctx, duk_small_int_t radix, duk_small_in
* is 1-2 kilobytes and nothing should rely on it being zeroed.
*/
#if 0
DUK_MEMSET((void *) nc_ctx, 0, sizeof(*nc_ctx)); /* slow init, do only for slow path cases */
DUK_MEMZERO((void *) nc_ctx, sizeof(*nc_ctx)); /* slow init, do only for slow path cases */
#endif
nc_ctx->is_s2n = 0;
@ -1661,7 +1661,7 @@ void duk_numconv_stringify(duk_context *ctx, duk_small_int_t radix, duk_small_in
}
DUK_DDDPRINT("count=%d", (int) count);
DUK_ASSERT(count >= 1);
DUK_MEMSET((void *) nc_ctx->digits, 0, count);
DUK_MEMZERO((void *) nc_ctx->digits, count);
nc_ctx->count = count;
nc_ctx->k = 1; /* 0.000... */
neg = 0;

2
src/duk_regexp_compiler.c

@ -912,7 +912,7 @@ void duk_regexp_compile(duk_hthread *thr) {
/* [ ... pattern flags escaped_source buffer ] */
DUK_MEMSET(&re_ctx, 0, sizeof(re_ctx));
DUK_MEMZERO(&re_ctx, sizeof(re_ctx));
DUK_LEXER_INITCTX(&re_ctx.lex); /* duplicate zeroing, expect for (possible) NULL inits */
re_ctx.thr = thr;
re_ctx.lex.thr = thr;

4
src/duk_regexp_executor.c

@ -491,7 +491,7 @@ static duk_uint8_t *duk__match_regexp(duk_re_matcher_ctx *re_ctx, duk_uint8_t *p
re_ctx->saved[idx] = NULL;
}
#else
DUK_MEMSET(re_ctx->saved + idx_start, 0, sizeof(duk_uint8_t *) * idx_count);
DUK_MEMZERO(re_ctx->saved + idx_start, sizeof(duk_uint8_t *) * idx_count);
#endif
sub_sp = duk__match_regexp(re_ctx, pc, sp);
@ -704,7 +704,7 @@ static void duk__regexp_match_helper(duk_hthread *thr, duk_small_int_t force_glo
/* [ ... re_obj input bc ] */
DUK_MEMSET(&re_ctx, 0, sizeof(re_ctx));
DUK_MEMZERO(&re_ctx, sizeof(re_ctx));
re_ctx.thr = thr;
re_ctx.input = (duk_uint8_t *) DUK_HSTRING_GET_DATA(h_input);

4
src/duk_unicode_support.c

@ -285,7 +285,7 @@ static duk_small_int_t duk__uni_range_match(const duk_uint8_t *unitab, duk_size_
duk_bitdecoder_ctx bd_ctx;
duk_codepoint_t prev_re;
DUK_MEMSET(&bd_ctx, 0, sizeof(bd_ctx));
DUK_MEMZERO(&bd_ctx, sizeof(bd_ctx));
bd_ctx.data = (duk_uint8_t *) unitab;
bd_ctx.length = (duk_size_t) unilen;
@ -825,7 +825,7 @@ static duk_codepoint_t duk__case_transform_helper(duk_hthread *thr,
}
/* 1:1 or special conversions, but not locale/context specific: script generated rules */
DUK_MEMSET(&bd_ctx, 0, sizeof(bd_ctx));
DUK_MEMZERO(&bd_ctx, sizeof(bd_ctx));
if (uppercase) {
bd_ctx.data = (duk_uint8_t *) duk_unicode_caseconv_uc;
bd_ctx.length = (duk_size_t) sizeof(duk_unicode_caseconv_uc);

Loading…
Cancel
Save