summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Buland <mbuland@penny-arcade.com>2019-05-22 12:34:08 -0700
committerMike Buland <mbuland@penny-arcade.com>2019-05-22 12:34:08 -0700
commitbb9e36f9c683ea888fd5c9ecde2f7c586a0238ac (patch)
treefffd2ca19c6e506191ec7232f1a8bf9065ab7c84
parent1eb9cf735de844d844f7d6191ac8b7bb9913214f (diff)
downloadlibbu++-bb9e36f9c683ea888fd5c9ecde2f7c586a0238ac.tar.gz
libbu++-bb9e36f9c683ea888fd5c9ecde2f7c586a0238ac.tar.bz2
libbu++-bb9e36f9c683ea888fd5c9ecde2f7c586a0238ac.tar.xz
libbu++-bb9e36f9c683ea888fd5c9ecde2f7c586a0238ac.zip
Fixed nasty null-string-int-conversion bug.v0.1
-rw-r--r--src/stable/string.cpp6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/stable/string.cpp b/src/stable/string.cpp
index 3029584..ed7be27 100644
--- a/src/stable/string.cpp
+++ b/src/stable/string.cpp
@@ -967,18 +967,24 @@ Bu::String Bu::String::toUpper() const
967int16_t Bu::String::toInt16( int iRadix ) const 967int16_t Bu::String::toInt16( int iRadix ) const
968{ 968{
969 flatten(); 969 flatten();
970 if( core->pFirst == NULL || core->nLength == 0 )
971 return 0;
970 return strtol( core->pFirst->pData, NULL, iRadix ); 972 return strtol( core->pFirst->pData, NULL, iRadix );
971} 973}
972 974
973int32_t Bu::String::toInt32( int iRadix ) const 975int32_t Bu::String::toInt32( int iRadix ) const
974{ 976{
975 flatten(); 977 flatten();
978 if( core->pFirst == NULL || core->nLength == 0 )
979 return 0;
976 return strtol( core->pFirst->pData, NULL, iRadix ); 980 return strtol( core->pFirst->pData, NULL, iRadix );
977} 981}
978 982
979int64_t Bu::String::toInt64( int iRadix ) const 983int64_t Bu::String::toInt64( int iRadix ) const
980{ 984{
981 flatten(); 985 flatten();
986 if( core->pFirst == NULL || core->nLength == 0 )
987 return 0;
982 return strtoll( core->pFirst->pData, NULL, iRadix ); 988 return strtoll( core->pFirst->pData, NULL, iRadix );
983} 989}
984 990