Skip to content

Commit 148688c

Browse files
authored
Do not try to insert empties into cont Lock (#117)
1 parent 97f5592 commit 148688c

1 file changed

Lines changed: 11 additions & 6 deletions

File tree

cdoc/Lock.cpp

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,18 +30,23 @@ namespace libcdoc {
3030
std::string
3131
Lock::getString(Params key) const
3232
{
33-
const std::vector<uint8_t>& bytes = params.at(key);
34-
return {(const char *) bytes.data(), bytes.size()};
33+
if (params.contains(key)) {
34+
const std::vector<uint8_t>& bytes = params.at(key);
35+
return {(const char *) bytes.data(), bytes.size()};
36+
}
37+
return {};
3538
}
3639

3740
int32_t
3841
Lock::getInt(Params key) const
3942
{
40-
const std::vector<uint8_t>& bytes = params.at(key);
4143
int32_t val = 0;
42-
for (int i = 0; (i < bytes.size()) && (i < 4); i++) {
43-
val = (val << 8) | bytes.at(i);
44-
}
44+
if (params.contains(key)) {
45+
const std::vector<uint8_t>& bytes = params.at(key);
46+
for (int i = 0; (i < bytes.size()) && (i < 4); i++) {
47+
val = (val << 8) | bytes.at(i);
48+
}
49+
}
4550
return val;
4651
}
4752

0 commit comments

Comments
 (0)