[Liblas-commits] hg: don't overwrite into an array that's too small
liblas-commits at liblas.org
liblas-commits at liblas.org
Tue May 4 13:17:35 EDT 2010
changeset 6f47f776555e in /Volumes/Data/www/liblas.org/hg
details: http://hg.liblas.orghg?cmd=changeset;node=6f47f776555e
summary: don't overwrite into an array that's too small
diffstat:
src/detail/writer/point.cpp | 7 ++++---
1 files changed, 4 insertions(+), 3 deletions(-)
diffs (27 lines):
diff -r 5a3c264b030e -r 6f47f776555e src/detail/writer/point.cpp
--- a/src/detail/writer/point.cpp Tue May 04 11:38:30 2010 -0500
+++ b/src/detail/writer/point.cpp Tue May 04 12:17:29 2010 -0500
@@ -156,19 +156,20 @@
blanks[i] = '\0';
}
detail::write_n(GetStream(), blanks, static_cast<std::streamsize>(size));
- delete [] blanks;
+ delete[] blanks;
} else if (data.size() != size){
int16_t difference = size - data.size();
if (difference < 0) {
throw std::runtime_error("Format's base size is larger than it's size. This should not happen!");
}
+
char* blanks = new char[difference];
- for (int i=0; i < size; ++i) {
+ for (int i=0; i < difference; ++i) {
blanks[i] = '\0';
}
detail::write_n(GetStream(), data.front(), data.size());
detail::write_n(GetStream(), blanks, static_cast<std::streamsize>(difference));
- delete [] blanks;
+ delete[] blanks;
} else {
detail::write_n(GetStream(), data.front(), static_cast<std::streamsize>(size));
More information about the Liblas-commits
mailing list