fix: double free with sub-pkgs (#112643).
authorjbj <devnull@localhost>
Fri, 26 Dec 2003 03:36:25 +0000 (03:36 +0000)
committerjbj <devnull@localhost>
Fri, 26 Dec 2003 03:36:25 +0000 (03:36 +0000)
CVS patchset: 7007
CVS date: 2003/12/26 03:36:25

file/src/apprentice.c

index 643dfe4..af1b1ef 100644 (file)
@@ -793,17 +793,13 @@ byteswap(/*@null@*/ struct magic *m, uint32_t nmagic)
 /*
  * make a dbname
  */
+/*@only@*/
 static char *
 mkdbname(const char *fn)
        /*@*/
 {
-       static const char ext[] = ".mgc";
-       /*@only@*/
-       static char *buf = NULL;
-
-       buf = xrealloc(buf, strlen(fn) + sizeof(ext) + 1);
-       (void)strcpy(buf, fn);
-       (void)strcat(buf, ext);
+       char * buf = xmalloc(strlen(fn) + sizeof(".mgc"));
+       (void) stpcpy( stpcpy(buf, fn), ".mgc");
        return buf;
 }