[Scummvm-git-logs] scummvm master -> 5a6e411bfd49b368925e2281f632bb383b770859

ccawley2011 ccawley2011 at gmail.com
Sun Sep 6 12:20:28 UTC 2020


This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
5a6e411bfd COMMON: Fix U32String::itoa when num is 0


Commit: 5a6e411bfd49b368925e2281f632bb383b770859
    https://github.com/scummvm/scummvm/commit/5a6e411bfd49b368925e2281f632bb383b770859
Author: Cameron Cawley (ccawley2011 at gmail.com)
Date: 2020-09-06T13:20:05+01:00

Commit Message:
COMMON: Fix U32String::itoa when num is 0

Changed paths:
    common/ustr.cpp


diff --git a/common/ustr.cpp b/common/ustr.cpp
index f3013ced65..b6a8a6c008 100644
--- a/common/ustr.cpp
+++ b/common/ustr.cpp
@@ -709,11 +709,15 @@ int U32String::vformat(U32String::const_iterator fmt, const U32String::const_ite
 char* U32String::itoa(int num, char* str, int base) {
 	int i = 0;
 
-	// go digit by digit
-	while (num != 0) {
-		int rem = num % base;
-		str[i++] = rem + '0';
-		num /= base;
+	if (num) {
+		// go digit by digit
+		while (num != 0) {
+			int rem = num % base;
+			str[i++] = rem + '0';
+			num /= base;
+		}
+	} else {
+		str[i++] = '0';
 	}
 
 	// append string terminator




More information about the Scummvm-git-logs mailing list