fix a potential null pointer reference in strdup (as found by Patrick Georgi)

Signed-off-by: Stefan Reinauer <stepan@coresystems.de>
Acked-by: Stefan Reinauer <stepan@coresystems.de>



git-svn-id: svn://svn.coreboot.org/coreboot/trunk@3902 2b7e53f0-3cfb-0310-b3e9-8179ed1497e1
This commit is contained in:
Stefan Reinauer 2009-01-26 00:57:54 +00:00 committed by Stefan Reinauer
parent 8c4421ddbd
commit ac29d61a45
1 changed files with 3 additions and 3 deletions

View File

@ -212,10 +212,10 @@ char *strdup(const char *s)
int n = strlen(s);
char *p = malloc(n + 1);
if (p != NULL)
if (p != NULL) {
strncpy(p, s, n);
p[n] = 0;
p[n] = 0;
}
return p;
}