hun#1999737 add some malloc checks
This commit is contained in:
parent
7107dea0c0
commit
e39ae52d7d
|
@ -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
|
||||||
|
|
10
csutil.c
10
csutil.c
|
@ -20,18 +20,20 @@ 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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue