Skip to content

Commit

Permalink
fix core dump when parsing csv with enclose
Browse files Browse the repository at this point in the history
  • Loading branch information
sollhui committed Dec 22, 2024
1 parent ac6cd94 commit 112a904
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -173,8 +173,9 @@ void EncloseCsvLineReaderContext::_on_pre_match_enclose(const uint8_t* start, si

void EncloseCsvLineReaderContext::_on_match_enclose(const uint8_t* start, size_t& len) {
const uint8_t* curr_start = start + _idx;
size_t curr_len = len - _idx;
const uint8_t* delim_pos =
find_col_sep_func(curr_start, _column_sep_len, _column_sep.c_str(), _column_sep_len);
find_col_sep_func(curr_start, curr_len, _column_sep.c_str(), _column_sep_len);

if (delim_pos != nullptr) [[likely]] {
on_col_sep_found(start, delim_pos);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,5 @@
3 abc"de,fg"h 2023-07-15 i\nj,k\n" 2023-07-20:05:48:31 ghi
6 ab"c 2023-07-20 d"ef" 2023-07-20:05:48:31 "g"hi
7 aaa 2023-07-20 2023-07-20:05:48:31
8 aaa"bbb"ccc 2023-07-20 "aa"bb 2023-07-20:05:48:31 aa"bb"
9 aa,"bbb cc" 2023-07-20 ""aa"bb ,2023-07-20:05:48:31,"aa"bb"
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
3 abc"de,fg"h 2023-07-15 i\nj,k\n" 2023-07-20T05:48:31 ghi
6 ab"c 2023-07-20 d"ef" 2023-07-20T05:48:31 "g"hi
7 aaa 2023-07-20 2023-07-20T05:48:31
8 aaa"bbb"ccc 2023-07-20 "aa"bb 2023-07-20T05:48:31 aa"bb"
9 aa,"bbb \N 2023-07-20 \N ,2023-07-20:05:48:31,"aa"bb"
10 ab@@cd@@efg 2023-07-20 ab@@cd$$$efg 2023-07-20T05:48:31 @@ab$$$cd$$$
10 ab@@cd@@efg 2023-07-20 ab@@cd$$$efg 2023-07-20T05:48:31 @@ab$$$cd$$$
10 abc \N "def" \N "ghi"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ suite("test_csv_with_enclose_and_escape", "p0") {
result, exception, startTime, endTime ->
assertTrue(exception == null)
def json = parseJson(result)
assertEquals("Fail", json.Status)
assertEquals("Success", json.Status)
}
}

Expand Down

0 comments on commit 112a904

Please sign in to comment.