Browse Source

Fix off-by-one memory allocation error in xstrdup.

master
Damien Goutte-Gattat 2 months ago
parent
commit
a3fc947567
  1. 4
      lib/xmem.c

4
lib/xmem.c

@ -76,8 +76,8 @@ xstrdup(const char *s)
size_t len;
len = strlen(s);
if ( ! (dup = malloc(len)) )
mem_error(len);
if ( ! (dup = malloc(len + 1)) )
mem_error(len + 1);
strcpy(dup, s);

Loading…
Cancel
Save