Skip to content

Commit

Permalink
Fix possible dereference of begin() iterator when std::vector is empty (
Browse files Browse the repository at this point in the history
  • Loading branch information
abtink authored Feb 18, 2020
1 parent cf3d099 commit 5157992
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/util/Data.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,11 @@ class Data : public std::vector<uint8_t> {
}

uint8_t* data() {
return &*begin();
return empty() ? NULL : &*begin();
}

const uint8_t* data() const {
return &*begin();
return empty() ? NULL : &*begin();
}
};
};
Expand Down

0 comments on commit 5157992

Please sign in to comment.