Fix #114847: Skip past more newlines when parsing PLY files
When parsing PLY files it was possible that the buffer would contain leading newline characters which were not being accounted for. Ensure we skip past them each time we refill the buffer. Also properly return an error string when handling such lines in the future. Pull Request: https://projects.blender.org/blender/blender/pulls/114878
This commit is contained in:
committed by
Jesse Yurkovich
parent
5c04b477aa
commit
3a312babe6
@@ -96,8 +96,12 @@ bool PlyReadBuffer::refill_buffer()
|
||||
pos_ = 0;
|
||||
buf_used_ = int(read);
|
||||
|
||||
/* Find last newline. */
|
||||
/* Skip past newlines at the front of the buffer and find last newline. */
|
||||
if (!is_binary_) {
|
||||
while (pos_ < buf_used_ && is_newline(buffer_[pos_])) {
|
||||
pos_++;
|
||||
}
|
||||
|
||||
int last_nl = buf_used_;
|
||||
if (!at_eof_) {
|
||||
while (last_nl > 0) {
|
||||
|
||||
@@ -131,6 +131,9 @@ static int get_index(const PlyElement &element, StringRef property)
|
||||
static const char *parse_row_ascii(PlyReadBuffer &file, Vector<float> &r_values)
|
||||
{
|
||||
Span<char> line = file.read_line();
|
||||
if (line.is_empty()) {
|
||||
return "Could not read row of ascii property";
|
||||
}
|
||||
|
||||
/* Parse whole line as floats. */
|
||||
const char *p = line.data();
|
||||
|
||||
Reference in New Issue
Block a user