summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2010-03-04 13:08:22 +0000
committerCaolán McNamara <caolanm@redhat.com>2010-03-04 13:08:22 +0000
commite39ae52d7d5f4d889a4b946c43aa9fc4b7178993 (patch)
tree478198f1e6306f10664e3807ed081ce67ab354be
parent7107dea0c0b64d5f0dc1b7b0c80734ca19a5f5c4 (diff)
downloadhyphen-e39ae52d7d5f4d889a4b946c43aa9fc4b7178993.tar.gz
hun#1999737 add some malloc checks
-rw-r--r--ChangeLog3
-rw-r--r--csutil.c24
2 files changed, 15 insertions, 12 deletions
diff --git a/ChangeLog b/ChangeLog
index afa9d93..6a2c4ec 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -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
diff --git a/csutil.c b/csutil.c
index 0555661..3ea3f57 100644
--- a/csutil.c
+++ b/csutil.c
@@ -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;
}