mirror of
https://github.com/systemd/systemd.git
synced 2024-11-01 09:21:26 +03:00
json: always allocate at least sizeof(JsonVariant) bytes
ubsan apparently doesn't like us being too smart here. Given the difference is just a few bytes, let's avoid the noise. Fixes: #13020
This commit is contained in:
parent
66d3159739
commit
2eb1c19881
@ -279,7 +279,8 @@ static int json_variant_new(JsonVariant **ret, JsonVariantType type, size_t spac
|
||||
|
||||
assert_return(ret, -EINVAL);
|
||||
|
||||
v = malloc0(offsetof(JsonVariant, value) + space);
|
||||
v = malloc0(MAX(sizeof(JsonVariant),
|
||||
offsetof(JsonVariant, value) + space));
|
||||
if (!v)
|
||||
return -ENOMEM;
|
||||
|
||||
@ -1664,7 +1665,8 @@ static int json_variant_copy(JsonVariant **nv, JsonVariant *v) {
|
||||
default:
|
||||
/* Everything else copy by reference */
|
||||
|
||||
c = malloc0(offsetof(JsonVariant, reference) + sizeof(JsonVariant*));
|
||||
c = malloc0(MAX(sizeof(JsonVariant),
|
||||
offsetof(JsonVariant, reference) + sizeof(JsonVariant*)));
|
||||
if (!c)
|
||||
return -ENOMEM;
|
||||
|
||||
@ -1677,7 +1679,8 @@ static int json_variant_copy(JsonVariant **nv, JsonVariant *v) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
c = malloc0(offsetof(JsonVariant, value) + k);
|
||||
c = malloc0(MAX(sizeof(JsonVariant),
|
||||
offsetof(JsonVariant, value) + k));
|
||||
if (!c)
|
||||
return -ENOMEM;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user