From: derek Date: Thu, 5 Jan 2012 19:55:19 +0000 (-0500) Subject: Fixed: bad_alloc in socket buffer on some machines X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=35eb5aa1ef552f0baccd9fc8cab61f3a13fe2adc;p=bamtools.git Fixed: bad_alloc in socket buffer on some machines --- diff --git a/src/api/internal/io/TcpSocket_p.cpp b/src/api/internal/io/TcpSocket_p.cpp index 6195710..1a5bd86 100644 --- a/src/api/internal/io/TcpSocket_p.cpp +++ b/src/api/internal/io/TcpSocket_p.cpp @@ -2,7 +2,7 @@ // TcpSocket_p.cpp (c) 2011 Derek Barnett // Marth Lab, Department of Biology, Boston College // --------------------------------------------------------------------------- -// Last modified: 8 December 2011 (DB) +// Last modified: 5 January 2012 (DB) // --------------------------------------------------------------------------- // Provides basic TCP I/O interface // *************************************************************************** @@ -14,6 +14,7 @@ using namespace BamTools; using namespace BamTools::Internal; #include +#include #include #include using namespace std; @@ -313,8 +314,8 @@ string TcpSocket::ReadLine(int64_t max) { // prep result byte buffer ByteArray result; - - size_t bufferMax = ((max > static_cast(string::npos)) ? string::npos : static_cast(max)); + size_t bufferMax = ((max > static_cast(UINT_MAX)) + ? UINT_MAX : static_cast(max)); result.Resize(bufferMax); // read data @@ -322,7 +323,7 @@ string TcpSocket::ReadLine(int64_t max) { if ( result.Size() == 0 ) { if ( bufferMax == 0 ) - bufferMax = string::npos; + bufferMax = UINT_MAX; result.Resize(1);