-
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?
Conversation
| 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); |
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.
This returns only the buffered bytes, not all remaining bytes as the memory io branch above
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.
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?
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.
This returns only the buffered bytes, not all remaining bytes as the memory io branch above
maybe use (int64_t) sizeof(reader->buffer) , Am I understanding this correctly?
lang/c/src/encoding_binary.c
Outdated
| // max := r.tail - r.head + 1; if max >= 0 && size > max | ||
| max_available = avro_max_read(reader); | ||
| if (max_available >= 0 && str_len > max_available) { | ||
| avro_set_error("mem io: String length %" PRId64 " is greater than available buffer size %" PRId64, |
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.
Please make sure to use the same indentation as the rest of the file, i.e. tabs.
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.

What is the purpose of the change
AVRO_SAFE_READto release memory upon exception return.Verifying this change
read_stringfunction to read them.Alternatively, you can use
valgrindto check for memory leaks.Documentation