Skip to content

Commit 6ff9c70

Browse files
committed
string terminator for windows
1 parent ba1c383 commit 6ff9c70

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/math.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ Uint8 math::hexstrToUint8(string s) {
8080

8181
string math::Uint8Tohexstr(Uint8 n) {
8282
Uint8 m;
83-
char s[2];
83+
char s[3];
8484
for(Int8 i = 1; i >= 0; i--) {
8585
m = n % 16;
8686
if(m < 10) {
@@ -91,12 +91,13 @@ string math::Uint8Tohexstr(Uint8 n) {
9191
}
9292
n /= 16;
9393
}
94+
s[2] = '\0';
9495
return s;
9596
}
9697

9798
string math::Uint16Tohexstr(Uint16 n) {
9899
Uint8 m;
99-
char s[4];
100+
char s[5];
100101
for(Int8 i = 3; i >= 0; i--) {
101102
m = n % 16;
102103
if(m < 10) {
@@ -107,15 +108,17 @@ string math::Uint16Tohexstr(Uint16 n) {
107108
}
108109
n /= 16;
109110
}
111+
s[4] = '\0';
110112
return s;
111113
}
112114

113115
string math::StatusRegisterToHexstr(StatusRegister sr) {
114-
char s[4];
116+
char s[5];
115117
s[0] = ((sr.Z) ? '1' : '0');
116118
s[1] = ((sr.N) ? '1' : '0');
117119
s[2] = ((sr.C) ? '1' : '0');
118120
s[3] = ((sr.V) ? '1' : '0');
121+
s[4] = '\0';
119122
return s;
120123
}
121124

0 commit comments

Comments
 (0)