mirror of
git://git.code.sf.net/p/cdesktopenv/code
synced 2025-03-09 15:50:02 +00:00
dtcm: Coverity 88006
This commit is contained in:
parent
3a4527980d
commit
c7a649afb9
1 changed files with 7 additions and 5 deletions
|
@ -623,7 +623,7 @@ extern char *
|
||||||
cm_mbchar(char *str) {
|
cm_mbchar(char *str) {
|
||||||
static char *string;
|
static char *string;
|
||||||
static char *string_head;
|
static char *string_head;
|
||||||
static char *buf;
|
static char *buf = NULL;
|
||||||
int num_byte = 0;
|
int num_byte = 0;
|
||||||
|
|
||||||
if ( str != NULL ) {
|
if ( str != NULL ) {
|
||||||
|
@ -644,10 +644,12 @@ cm_mbchar(char *str) {
|
||||||
string_head = NULL;
|
string_head = NULL;
|
||||||
} else {
|
} else {
|
||||||
num_byte = mblen(string, MB_LEN_MAX);
|
num_byte = mblen(string, MB_LEN_MAX);
|
||||||
buf = (char *)malloc(num_byte+1);
|
if(num_byte > 0) {
|
||||||
strncpy(buf, string, num_byte);
|
buf = (char *)malloc(num_byte+1);
|
||||||
buf[num_byte] = '\0';
|
strncpy(buf, string, num_byte);
|
||||||
string += num_byte;
|
buf[num_byte] = '\0';
|
||||||
|
string += num_byte;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return buf;
|
return buf;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue