sc.h: correct access violation in load_key_vector(), close #2.
In load_key_vector(), the program passes a std::vector<byte> to
a C-style function, load_key (const byte*begin, const byte*end)
by creating references
load_key (& (K[0]), & (K[K.size()]));
However, accessing the one-past-the-last element in a std::vector
via [] is not allowed in C++, it triggers an assertion failure.
Assertion '__builtin_expect(__n < this->size(), true)' failed.
In this commit, we use K.data() and K.data() + K.size() to expose
the underlying pointers and pass them to the C function.
Signed-off-by: Tom Li <tomli@tomli.me>
This commit is contained in:
parent
4441f8e514
commit
7021f6c734
2
src/sc.h
2
src/sc.h
|
|
@ -50,7 +50,7 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
void load_key_vector (const std::vector<byte>&K) {
|
void load_key_vector (const std::vector<byte>&K) {
|
||||||
load_key (& (K[0]), & (K[K.size()]));
|
load_key (K.data(), K.data() + K.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
typedef std::map<std::string, factoryof<streamcipher>*> suite_t;
|
typedef std::map<std::string, factoryof<streamcipher>*> suite_t;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue