File tree Expand file tree Collapse file tree 1 file changed +6
-3
lines changed Expand file tree Collapse file tree 1 file changed +6
-3
lines changed Original file line number Diff line number Diff line change @@ -80,7 +80,7 @@ Uint8 math::hexstrToUint8(string s) {
8080
8181string 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
9798string 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
113115string 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
You can’t perform that action at this time.
0 commit comments