diff options
author | Eelco Dolstra <edolstra@gmail.com> | 2018-05-02 13:56:34 +0200 |
---|---|---|
committer | Eelco Dolstra <edolstra@gmail.com> | 2018-05-02 13:56:34 +0200 |
commit | 53ec5ac69f59ac435b18297a594933e83e236766 (patch) | |
tree | f50797b3f3338de1d471a9b6f3b3e377813f09c9 /src/libexpr/attr-set.cc | |
parent | 548ad391d96d8922d0f8c35b5dd72bf4fb7e3ed1 (diff) |
Fix some random -Wconversion warnings
Diffstat (limited to 'src/libexpr/attr-set.cc')
-rw-r--r-- | src/libexpr/attr-set.cc | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/src/libexpr/attr-set.cc b/src/libexpr/attr-set.cc index b284daa3c..0474865c6 100644 --- a/src/libexpr/attr-set.cc +++ b/src/libexpr/attr-set.cc @@ -24,13 +24,15 @@ static void * allocBytes(size_t n) /* Allocate a new array of attributes for an attribute set with a specific capacity. The space is implicitly reserved after the Bindings structure. */ -Bindings * EvalState::allocBindings(Bindings::size_t capacity) +Bindings * EvalState::allocBindings(size_t capacity) { - return new (allocBytes(sizeof(Bindings) + sizeof(Attr) * capacity)) Bindings(capacity); + if (capacity > std::numeric_limits<Bindings::size_t>::max()) + throw Error("attribute set of size %d is too big", capacity); + return new (allocBytes(sizeof(Bindings) + sizeof(Attr) * capacity)) Bindings((Bindings::size_t) capacity); } -void EvalState::mkAttrs(Value & v, unsigned int capacity) +void EvalState::mkAttrs(Value & v, size_t capacity) { if (capacity == 0) { v = vEmptySet; |