Chameleon

Chameleon Commit Details

Date:2014-10-23 05:51:20 (9 years 4 months ago)
Author:Chuck Fry
Commit:2438
Parents: 2437
Message:Only write terminating null char if malloc succeeded
Changes:
M/branches/chucko/i386/modules/klibc/strndup.c

File differences

branches/chucko/i386/modules/klibc/strndup.c
99
1010
1111
12
13
14
12
13
14
15
1516
1617
int l = n > strlen(s) ? strlen(s) + 1 : n + 1;
char *d = malloc(l);
if (d)
memcpy(d, s, l);
d[n] = '\0';
if (d) {
memcpy(d, s, l);
d[n] = '\0';
}
return d;
}

Archive Download the corresponding diff file

Revision: 2438