* glob.c (ftpglob): Always allocate new storage, even if no magic glob
authorKen Raeburn <raeburn@mit.edu>
Wed, 22 Apr 1998 01:30:40 +0000 (01:30 +0000)
committerKen Raeburn <raeburn@mit.edu>
Wed, 22 Apr 1998 01:30:40 +0000 (01:30 +0000)
characters were found, because the caller will always free the storage.

git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@10539 dc483132-0cff-0310-8789-dd5450dbe970

src/appl/gssftp/ftp/ChangeLog
src/appl/gssftp/ftp/glob.c

index 9fbe76b1230aa147ee07d26bad1e5d1f8af6b884..f56f5985e50212b3b5bd36bf1e9ea52227b8d35b 100644 (file)
@@ -1,3 +1,9 @@
+1998-04-21  Ken Raeburn  <raeburn@cygnus.com>
+
+       * glob.c (ftpglob): Always allocate new storage, even if no magic
+       glob characters were found, because the caller will always free
+       the storage.
+
 Tue Apr  7 16:53:58 1998  Dan Winship  <danw@mit.edu>
 
        * secure.c (secure_putbyte): Set nout = 0 *before* calling
index 3a793d83eb4ddc4c47c143eb887780a4011861d1..f92ee5e079785ed36eb631e9fcf3a9a00e8da77d 100644 (file)
@@ -104,8 +104,17 @@ ftpglob(v)
        vv[1] = 0;
        gflag = 0;
        rscan(vv, tglob);
-       if (gflag == 0)
-               return (copyblk(vv));
+       if (gflag == 0) {
+         /* Caller will always free the contents, so make a copy.  */
+         size_t len = strlen (v) + 1;
+         vv[0] = malloc (len);
+         if (vv[0] == 0) {
+           globerr = "Can't allocate memory";
+           return 0;
+         }
+         memcpy (vv[0], v, len);
+         return (copyblk(vv));
+       }
 
        globerr = 0;
        gpath = agpath; gpathp = gpath; *gpathp = 0;