pitrou commented on code in PR #45498: URL: https://github.com/apache/arrow/pull/45498#discussion_r1952296698
########## cpp/src/arrow/csv/parser_test.cc: ########## @@ -724,6 +767,35 @@ TEST(BlockParser, MismatchingNumColumnsHandler) { ASSERT_NO_FATAL_FAILURE(AssertLastRowEq(parser, {"j", "k"}, {false, false})); } + + // Vary the number of columns and mismatch, to catch buffer overflow issues + for (int32_t num_cols : {1, 2, 5, 10, 100}) { + ARROW_SCOPED_TRACE("num_cols = ", num_cols); + for (int32_t mismatch : {-20, -5, -4, -1, 1, 2, 5, 10, 50, 1024, 32767}) { + if (mismatch + num_cols <= 0) { + continue; + } + ARROW_SCOPED_TRACE("mismatch = ", mismatch); + // Parse CSV data + auto csv_data = MismatchingNumColumns(num_cols, mismatch, /*extra_lines=*/1); + ParseOptions opts = ParseOptions::Defaults(); + CustomHandler handler; + opts.invalid_row_handler = handler; + BlockParser parser(opts, num_cols, /*first_row=*/1); + ASSERT_NO_FATAL_FAILURE(AssertParseOk(parser, MakeCSVData(csv_data))); Review Comment: TBH I don't really know why, I just copied the structure of existing tests. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: github-unsubscr...@arrow.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org