diff options
| author | Caolán McNamara <caolanm@redhat.com> | 2010-03-04 13:08:22 +0000 |
|---|---|---|
| committer | Caolán McNamara <caolanm@redhat.com> | 2010-03-04 13:08:22 +0000 |
| commit | e39ae52d7d5f4d889a4b946c43aa9fc4b7178993 (patch) | |
| tree | 478198f1e6306f10664e3807ed081ce67ab354be | |
| parent | 7107dea0c0b64d5f0dc1b7b0c80734ca19a5f5c4 (diff) | |
| download | hyphen-e39ae52d7d5f4d889a4b946c43aa9fc4b7178993.tar.gz | |
hun#1999737 add some malloc checks
| -rw-r--r-- | ChangeLog | 3 | ||||
| -rw-r--r-- | csutil.c | 24 |
2 files changed, 15 insertions, 12 deletions
@@ -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 @@ -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; } |
