From 79d8352018fa0dcc6db4f14ee0bf91a68dbd18b1 Mon Sep 17 00:00:00 2001 From: ksherlock Date: Mon, 31 May 2010 16:03:26 +0000 Subject: [PATCH] fix data() git-svn-id: https://profuse.googlecode.com/svn/branches/v2@313 aa027e90-d47c-11dd-86d7-074df07e0730 --- Pascal/TextWriter.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/Pascal/TextWriter.cpp b/Pascal/TextWriter.cpp index dff4a79..309f4f4 100644 --- a/Pascal/TextWriter.cpp +++ b/Pascal/TextWriter.cpp @@ -42,11 +42,13 @@ unsigned TextWriter::blocks() const void *TextWriter::data(unsigned block) const { unsigned offset = (block & 0x01) * 512; - if (( block >> 1 ) < _blocks.size()) + unsigned halfBlock = block >> 1; + + if (halfBlock < _blocks.size()) { - return _blocks[block >> 1] + offset; + return _blocks[halfBlock] + offset; } - if (block == _blocks.size()) + if (halfBlock == _blocks.size()) { if (offset > _offset) return NULL; return _current + offset; @@ -83,8 +85,8 @@ void TextWriter::writeLine(const char *line, unsigned length) text.push_back(0x0d); } - length = text.length(); + if (length > 1024) { throw ProFUSE::Exception(__METHOD__ ": String is too long.");