Skip to content

Commit be3f5fc

Browse files
author
yzh
committedMar 5, 2014
fix bug for exceeding bounary in function itoa()
1 parent d87c386 commit be3f5fc

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed
 

‎src/lib/string.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*/
99
char *itoa(int a) {
1010
static char buf[30];
11-
char *p = buf + sizeof(buf);
11+
char *p = buf + sizeof(buf) - 1;
1212
do {
1313
*--p = '0' + a % 10;
1414
} while (a /= 10);

0 commit comments

Comments
 (0)
Please sign in to comment.