Skip to content

Commit

Permalink
Fixed: issue #1946
Browse files Browse the repository at this point in the history
  • Loading branch information
bobhyun committed Sep 21, 2024
1 parent 7c4799d commit b9f7ee9
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions httplib.h
Original file line number Diff line number Diff line change
Expand Up @@ -5104,16 +5104,19 @@ inline bool range_error(Request &req, Response &res) {
}

// Ranges must be in ascending order
if (first_pos <= prev_first_pos) { return true; }
if (prev_first_pos != -1 && // Fixed: checking initial value
first_pos <= prev_first_pos) { return true; }

// Request must not have more than two overlapping ranges
if (first_pos <= prev_last_pos) {
if (prev_last_pos != -1 && // Fixed: checking initial value
first_pos <= prev_last_pos) {
overwrapping_count++;
if (overwrapping_count > 2) { return true; }
}

prev_first_pos = (std::max)(prev_first_pos, first_pos);
prev_last_pos = (std::max)(prev_last_pos, last_pos);
// Fixed: checking initial values
prev_first_pos = (prev_first_pos == -1) ? first_pos : (std::max)(prev_first_pos, first_pos);
prev_last_pos = (prev_last_pos == -1) ? last_pos : (std::max)(prev_last_pos, last_pos);
}
}

Expand Down

0 comments on commit b9f7ee9

Please sign in to comment.