-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Fixes a memory leak issue in the Avro C library under abnormal data scenarios. #3635
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 |
|---|---|---|
|
|
@@ -274,6 +274,20 @@ int avro_read(avro_reader_t reader, void *buf, int64_t len) | |
| return EINVAL; | ||
| } | ||
|
|
||
|
|
||
| int64_t avro_max_read(avro_reader_t reader) | ||
| { | ||
| if (is_memory_io(reader)) { | ||
| struct _avro_reader_memory_t *mem_reader = avro_reader_to_memory(reader); | ||
| return mem_reader->len - mem_reader->read; | ||
| } else if (is_file_io(reader)) { | ||
| struct _avro_reader_file_t *file_reader = avro_reader_to_file(reader); | ||
| return bytes_available(file_reader); | ||
|
Member
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. This returns only the buffered bytes, not all remaining bytes as the memory io branch above
Author
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. sorry, I haven't found a way to get the remaining buffer length for file I/O. My goal is to check the maximum readable length before malloc to avoid memory leaks caused by the length exceeding the limit during avro_read_memory checks. Are there any other good solutions?
Author
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.
maybe use |
||
| } | ||
| return -1; | ||
| } | ||
|
|
||
|
|
||
| static int avro_skip_memory(struct _avro_reader_memory_t *reader, int64_t len) | ||
| { | ||
| if (len > 0) { | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.