mirror of
https://github.com/fish-shell/fish-shell.git
synced 2024-11-24 09:23:38 +08:00
Fix te_expr's flexible array member
te_expr has a flexible array member, but it's declared as size 1. Stop declaring its size so UBSan stops complaining. Noted in #2852
This commit is contained in:
parent
6025c28efc
commit
26ada583a0
|
@ -56,7 +56,7 @@ int get_arity(const int type) {
|
||||||
typedef struct te_expr {
|
typedef struct te_expr {
|
||||||
int type;
|
int type;
|
||||||
union {double value; const void *function;};
|
union {double value; const void *function;};
|
||||||
te_expr *parameters[1];
|
te_expr *parameters[];
|
||||||
} te_expr;
|
} te_expr;
|
||||||
|
|
||||||
// TODO: Rename since variables have been removed.
|
// TODO: Rename since variables have been removed.
|
||||||
|
@ -92,7 +92,7 @@ void te_free(te_expr *n);
|
||||||
static te_expr *new_expr(const int type, const te_expr *parameters[]) {
|
static te_expr *new_expr(const int type, const te_expr *parameters[]) {
|
||||||
const int arity = get_arity(type);
|
const int arity = get_arity(type);
|
||||||
const int psize = sizeof(te_expr*) * arity;
|
const int psize = sizeof(te_expr*) * arity;
|
||||||
const int size = (sizeof(te_expr) - sizeof(void*)) + psize;
|
const int size = sizeof(te_expr) + psize;
|
||||||
te_expr *ret = (te_expr *)malloc(size);
|
te_expr *ret = (te_expr *)malloc(size);
|
||||||
// This sets float to 0, which depends on the implementation.
|
// This sets float to 0, which depends on the implementation.
|
||||||
// We rely on IEEE-754 floats anyway, so it's okay.
|
// We rely on IEEE-754 floats anyway, so it's okay.
|
||||||
|
|
Loading…
Reference in New Issue
Block a user