highfidelity/hifi — pull request #3356 by ZappoMan (2014-09-05 08:20:03+00:00)
Title: fix huge-mega-voxels and voxel file corruption

This should fix the random "large voxels in space" problem that has been plaguing us for a while.

The root of the problem is that the old old old old voxel parsing code would read from a buffer but didn't check to see if the buffer contained enough bytes to keep reading. This would cause the parsing code to run off into memory and read in garbage. After much debugging, I determined that these corrupts were not happening on edits or on file saving (see note below) -- but instead on reading in the files.

Note: there may also be some bug in writing that writes extra bytes to the end of buffers -- but this PR will fix the reading to guard against that case.