[Liblas-commits] hg-main-tree: throw buffer_too_small error when user requested a...

liblas-commits at liblas.org liblas-commits at liblas.org
Thu Apr 14 14:45:54 EDT 2011


details:   http://hg.libpc.orghg-main-tree/rev/e1b1e9a852d4
changeset: 567:e1b1e9a852d4
user:      Howard Butler <hobu.inc at gmail.com>
date:      Thu Apr 14 13:45:48 2011 -0500
description:
throw buffer_too_small error when user requested a buffer that won't fit the oracle block

diffstat:

 include/libpc/drivers/oci/Common.hpp |  9 +++++++++
 src/drivers/oci/Iterator.cpp         |  9 +++++++--
 2 files changed, 16 insertions(+), 2 deletions(-)

diffs (50 lines):

diff -r 55b2a8004225 -r e1b1e9a852d4 include/libpc/drivers/oci/Common.hpp
--- a/include/libpc/drivers/oci/Common.hpp	Thu Apr 14 10:26:10 2011 -0500
+++ b/include/libpc/drivers/oci/Common.hpp	Thu Apr 14 13:45:48 2011 -0500
@@ -69,6 +69,15 @@
     {}
 };
 
+// use this for code still under development
+class buffer_too_small : public libpc_error
+{
+public:
+    buffer_too_small(std::string const& msg)
+        : libpc_error(msg)
+    {}
+};
+
 
 #ifdef LIBPC_COMPILER_MSVC
 #define compare_no_case(a,b,n)  _strnicmp( (a), (b), (n) )
diff -r 55b2a8004225 -r e1b1e9a852d4 src/drivers/oci/Iterator.cpp
--- a/src/drivers/oci/Iterator.cpp	Thu Apr 14 10:26:10 2011 -0500
+++ b/src/drivers/oci/Iterator.cpp	Thu Apr 14 13:45:48 2011 -0500
@@ -182,12 +182,17 @@
         // We still have a block of data from the last readBuffer call
         // that was partially read. 
         // std::cout << "reading because we have no points" << std::endl;
-        bDidRead = m_statement->Fetch();
+        bDidRead = m_statement->Fetch();        
         if (!bDidRead)
         {
             m_at_end = true;
             return 0;
         }
+        
+        if (m_block->num_points > data.getCapacity())
+        {
+            throw buffer_too_small("The PointBuffer is too small to contain this block.");
+        }
     
     } else 
     {
@@ -201,7 +206,7 @@
     while (bDidRead)
     {
         boost::uint32_t numReadThisBlock = m_block->num_points;
-        if ((numReadThisBlock) > (data.getCapacity() - data.getNumPoints()))
+        if (numReadThisBlock > (data.getCapacity() - data.getNumPoints()))
         {
             // We're done.  We still have more data, but the 
             // user is going to have to request another buffer.


More information about the Liblas-commits mailing list