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:
parent
8c4421ddbd
commit
ac29d61a45
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue