File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -30,18 +30,23 @@ namespace libcdoc {
3030std::string
3131Lock::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
3740int32_t
3841Lock::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
You can’t perform that action at this time.
0 commit comments