diff options
author | Mike Buland <mbuland@penny-arcade.com> | 2019-05-22 12:34:08 -0700 |
---|---|---|
committer | Mike Buland <mbuland@penny-arcade.com> | 2019-05-22 12:34:08 -0700 |
commit | bb9e36f9c683ea888fd5c9ecde2f7c586a0238ac (patch) | |
tree | fffd2ca19c6e506191ec7232f1a8bf9065ab7c84 | |
parent | 1eb9cf735de844d844f7d6191ac8b7bb9913214f (diff) | |
download | libbu++-2337457995505c6903196830bd05ada7d58b2be8.tar.gz libbu++-2337457995505c6903196830bd05ada7d58b2be8.tar.bz2 libbu++-2337457995505c6903196830bd05ada7d58b2be8.tar.xz libbu++-2337457995505c6903196830bd05ada7d58b2be8.zip |
Fixed nasty null-string-int-conversion bug.v0.1
-rw-r--r-- | src/stable/string.cpp | 6 |
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 | |||
967 | int16_t Bu::String::toInt16( int iRadix ) const | 967 | int16_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 | ||
973 | int32_t Bu::String::toInt32( int iRadix ) const | 975 | int32_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 | ||
979 | int64_t Bu::String::toInt64( int iRadix ) const | 983 | int64_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 | ||