From 35eb5aa1ef552f0baccd9fc8cab61f3a13fe2adc Mon Sep 17 00:00:00 2001 From: derek Date: Thu, 5 Jan 2012 14:55:19 -0500 Subject: [PATCH] Fixed: bad_alloc in socket buffer on some machines --- src/api/internal/io/TcpSocket_p.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) 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); -- 2.39.2