------------------------------------------------------------ revno: 709 committer: Giovanni Campagna branch nick: simple-scan timestamp: Thu 2014-06-26 16:49:22 +0200 message: Fix buffer handling with recent vala In recent vala, assigning from an array to another owned array will clear the first one, so when we access buffer.lenght later it will be zero. This, added with the wrong full_read logic for n_used != 0, would cause an empty buffer at the end of do_read(), and an infinite loop trying to always read 0 bytes. === modified file 'src/scanner.vala' --- src/scanner.vala 2013-11-01 00:57:54 +0000 +++ src/scanner.vala 2014-06-26 14:49:22 +0000 @@ -1331,7 +1331,7 @@ } bool full_read = false; - if (n_used == 0 && n_read == buffer.length) + if (n_used + n_read == buffer.length) full_read = true; n_used += (int) n_read; @@ -1359,6 +1359,8 @@ } line.width = parameters.pixels_per_line; line.depth = parameters.depth; + + var buffer_size = buffer.length; line.data = (owned) buffer; line.data_length = parameters.bytes_per_line; line.number = line_count; @@ -1367,7 +1369,6 @@ line_count += line.n_lines; /* Increase buffer size if did full read */ - var buffer_size = buffer.length; if (full_read) buffer_size += parameters.bytes_per_line;