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>: 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>: 2010-02-23 László Németh <nemeth at OOo>:
* hyphen.c: fix lefthyphenmin calculation for UTF-8 encoded input * hyphen.c: fix lefthyphenmin calculation for UTF-8 encoded input

View File

@ -20,19 +20,21 @@ char * mystrsep(char ** stringp, const char delim)
*stringp = dp+1; *stringp = dp+1;
nc = (int)((unsigned long)dp - (unsigned long)mp); nc = (int)((unsigned long)dp - (unsigned long)mp);
rv = (char *) malloc(nc+1); rv = (char *) malloc(nc+1);
if (rv) {
memcpy(rv,mp,nc); memcpy(rv,mp,nc);
*(rv+nc) = '\0'; *(rv+nc) = '\0';
return rv; }
} else { } else {
rv = (char *) malloc(n+1); rv = (char *) malloc(n+1);
if (rv) {
memcpy(rv, mp, n); memcpy(rv, mp, n);
*(rv+n) = '\0'; *(rv+n) = '\0';
*stringp = mp + n; *stringp = mp + n;
}
}
}
return rv; return rv;
} }
}
return NULL;
}
/* replaces strdup with ansi version */ /* replaces strdup with ansi version */