-
Notifications
You must be signed in to change notification settings - Fork 2
fix: use csv_config_copy to ensure config is properly duplicated in CSV Reader #16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -20,7 +20,7 @@ CSVReader* csv_reader_init_with_config(Arena *persistent_arena, Arena *temp_aren | |||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| reader->persistent_arena = persistent_arena; | ||||||||||||||||||||||||||||||||||||||
| reader->temp_arena = temp_arena; | ||||||||||||||||||||||||||||||||||||||
| reader->config = config; | ||||||||||||||||||||||||||||||||||||||
| reader->config = csv_config_copy(persistent_arena, config); | ||||||||||||||||||||||||||||||||||||||
| reader->headers_loaded = false; | ||||||||||||||||||||||||||||||||||||||
| reader->cached_header_count = 0; | ||||||||||||||||||||||||||||||||||||||
| reader->cached_headers = NULL; | ||||||||||||||||||||||||||||||||||||||
|
|
@@ -90,7 +90,7 @@ CSVReader* csv_reader_init_standalone(CSVConfig *config) { | |||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| reader->persistent_arena = persistent_arena; | ||||||||||||||||||||||||||||||||||||||
| reader->temp_arena = temp_arena; | ||||||||||||||||||||||||||||||||||||||
| reader->config = config; | ||||||||||||||||||||||||||||||||||||||
| reader->config = csv_config_copy(persistent_arena, config); | ||||||||||||||||||||||||||||||||||||||
| reader->headers_loaded = false; | ||||||||||||||||||||||||||||||||||||||
|
Comment on lines
91
to
94
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🩺 Stability & Availability | 🟠 Major | ⚡ Quick win Missing NULL check on Same issue as 🛡️ Proposed fix reader->persistent_arena = persistent_arena;
reader->temp_arena = temp_arena;
- reader->config = csv_config_copy(persistent_arena, config);
+ reader->config = csv_config_copy(persistent_arena, config);
+ if (!reader->config) {
+ fclose(reader->file);
+ arena_destroy(persistent_arena);
+ arena_destroy(temp_arena);
+ free(persistent_arena);
+ free(temp_arena);
+ free(reader);
+ return NULL;
+ }
reader->headers_loaded = false;📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||
| reader->cached_header_count = 0; | ||||||||||||||||||||||||||||||||||||||
| reader->cached_headers = NULL; | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🩺 Stability & Availability | 🟠 Major | ⚡ Quick win
Missing NULL check on
csv_config_copyresult.csv_config_copyreturnsNULLon allocation failure (seecsv_config.c:32-42), but the result is stored directly intoreader->configwithout validation. Ifpersistent_arenaallocation fails here,readeris still returned to the caller with aNULLconfig, which will crash later whereverreader->configis dereferenced.🛡️ Proposed fix
reader->persistent_arena = persistent_arena; reader->temp_arena = temp_arena; - reader->config = csv_config_copy(persistent_arena, config); + reader->config = csv_config_copy(persistent_arena, config); + if (!reader->config) { + fclose(reader->file); + return NULL; + } reader->headers_loaded = false;📝 Committable suggestion
🤖 Prompt for AI Agents