hun#1999737 add some malloc checks

This commit is contained in:
Caolán McNamara 2010-03-04 13:08:22 +00:00
parent 7107dea0c0
commit e39ae52d7d
2 changed files with 15 additions and 12 deletions

View File

@ -1,5 +1,6 @@
2010-03-04 Caolán McNamara <cmc at OOo>:
- hun#1724558 tidy substring.c a little
* hun#1724558 tidy substring.c a little
* hun#1999737 add some malloc checks
2010-02-23 László Németh <nemeth at OOo>:
* hyphen.c: fix lefthyphenmin calculation for UTF-8 encoded input

View File

@ -17,21 +17,23 @@ char * mystrsep(char ** stringp, const char delim)
char * dp = (char *)memchr(mp,(int)((unsigned char)delim),n);
if (dp) {
int nc;
*stringp = dp+1;
nc = (int)((unsigned long)dp - (unsigned long)mp);
rv = (char *) malloc(nc+1);
memcpy(rv,mp,nc);
*(rv+nc) = '\0';
return rv;
*stringp = dp+1;
nc = (int)((unsigned long)dp - (unsigned long)mp);
rv = (char *) malloc(nc+1);
if (rv) {
memcpy(rv,mp,nc);
*(rv+nc) = '\0';
}
} else {
rv = (char *) malloc(n+1);
memcpy(rv, mp, n);
*(rv+n) = '\0';
*stringp = mp + n;
return rv;
if (rv) {
memcpy(rv, mp, n);
*(rv+n) = '\0';
*stringp = mp + n;
}
}
}
return NULL;
return rv;
}