Skip to content

Commit 3f189a3

Browse files
committed
Fixed a bug that might invoke undefined behavior
Calling front() on an empty container would invoke undefined behavior
1 parent 4e81197 commit 3f189a3

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

C++/chapSearching.tex

+1
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,7 @@ \subsubsection{代码}
179179
class Solution {
180180
public:
181181
bool searchMatrix(const vector<vector<int>>& matrix, int target) {
182+
if (matrix.empty()) return false;
182183
const size_t m = matrix.size();
183184
const size_t n = matrix.front().size();
184185

0 commit comments

Comments
 (0)