Skip to content

Commit 3a3dc72

Browse files
Fix invalid memory access issue in g++ builds (#228)
* Try to use shared_ptr<CSVField> to avoid memory issues * Run tests * Update single include * Also added test for empty file SEGFAULT * diD yoU forGet to #incLude<cStrIng>
1 parent 0ef1cff commit 3a3dc72

File tree

8 files changed

+1838
-1860
lines changed

8 files changed

+1838
-1860
lines changed

.github/workflows/cmake-multi-platform.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ name: CMake on multiple platforms
44

55
on:
66
push:
7-
branches: [ "master", "gcc-error" ]
7+
branches: [ "master", "memory-fix-gcc" ]
88
pull_request:
99
branches: [ "master" ]
1010

include/csv.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
CSV for C++, version 2.2.1
2+
CSV for C++, version 2.2.2
33
https://github.com/vincentlaucsb/csv-parser
44
55
MIT License

include/internal/csv_row.cpp

-5
Original file line numberDiff line numberDiff line change
@@ -204,12 +204,7 @@ namespace csv {
204204
}
205205

206206
CSV_INLINE CSVRow::iterator::pointer CSVRow::iterator::operator->() const {
207-
// Using CSVField * as pointer type causes segfaults in MSVC debug builds
208-
#ifdef _MSC_BUILD
209207
return this->field;
210-
#else
211-
return this->field.get();
212-
#endif
213208
}
214209

215210
CSV_INLINE CSVRow::iterator& CSVRow::iterator::operator++() {

include/internal/csv_row.hpp

-8
Original file line numberDiff line numberDiff line change
@@ -337,15 +337,7 @@ namespace csv {
337337
#ifndef DOXYGEN_SHOULD_SKIP_THIS
338338
using value_type = CSVField;
339339
using difference_type = int;
340-
341-
// Using CSVField * as pointer type causes segfaults in MSVC debug builds
342-
// but using shared_ptr as pointer type won't compile in g++
343-
#ifdef _MSC_BUILD
344340
using pointer = std::shared_ptr<CSVField>;
345-
#else
346-
using pointer = CSVField * ;
347-
#endif
348-
349341
using reference = CSVField & ;
350342
using iterator_category = std::random_access_iterator_tag;
351343
#endif

0 commit comments

Comments
 (0)