Skip to content

Commit

Permalink
portability: memcpy of size zero is undefined behaviour
Browse files Browse the repository at this point in the history
  • Loading branch information
radare committed Jan 27, 2023
1 parent 65cfe08 commit b02ef8d
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions quickjs.c
Original file line number Diff line number Diff line change
Expand Up @@ -32777,8 +32777,10 @@ static JSValue js_create_function(JSContext *ctx, JSFunctionDef *fd)
}
} else {
b->vardefs = (void *)((uint8_t*)b + vardefs_offset);
memcpy(b->vardefs, fd->args, fd->arg_count * sizeof(fd->args[0]));
memcpy(b->vardefs + fd->arg_count, fd->vars, fd->var_count * sizeof(fd->vars[0]));
if (fd->vars && fd->arg_count > 0) {
memcpy(b->vardefs, fd->args, fd->arg_count * sizeof(fd->args[0]));
memcpy(b->vardefs + fd->arg_count, fd->vars, fd->var_count * sizeof(fd->vars[0]));
}
}
b->var_count = fd->var_count;
b->arg_count = fd->arg_count;
Expand Down

0 comments on commit b02ef8d

Please sign in to comment.