match the trailing \0 of a string) we need to check that first, otherwise
we end up with incorrect results. Fix suggested by reporter.
(closes issue #13787)
Reported by: meitinger
git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.4@152059
65c4cc65-6c06-0410-ace0-
fbb531ad65f3
char *bufptr, *dataptr;
for (bufptr = buf, dataptr = data; bufptr < buf + len - 1; dataptr++) {
- if (*dataptr == '1') {
+ if (*dataptr == '\0') {
+ *bufptr++ = '\0';
+ break;
+ } else if (*dataptr == '1') {
*bufptr++ = '1';
} else if (strchr("AaBbCc2", *dataptr)) {
*bufptr++ = '2';
*bufptr++ = '9';
} else if (*dataptr == '0') {
*bufptr++ = '0';
- } else if (*dataptr == '\0') {
- *bufptr++ = '\0';
- break;
}
}
buf[len - 1] = '\0';