This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

mkshortcut (cygutils-1.4.14) free error


Seems free() is being called on an adjusted pointer,  causing general
misbehaviour.  A minimal patch below.

Anthony


--- src/mkshortcut/mkshortcut.c.Orig    2015-10-17 21:57:08.000000000
-0400
+++ src/mkshortcut/mkshortcut.c 2015-10-17 22:16:41.269357400 -0400
@@ -412,7 +412,7 @@
   char* exe_name = NULL;
   char* dir_name = NULL;
   char* desc = NULL;
-  char *buf_str, *tmp_str;
+  char *buf_str, *tmp_str, *base_str;
   int tmp;
 
   /* For OLE interface */
@@ -489,6 +489,7 @@
     {
       /*  Strip trailing /'s if any */
       buf_str = xstrndup (opts.target_arg, strlen(opts.target_arg));
+      base_str = buf_str;
       tmp_str = buf_str;
       tmp = strlen (buf_str) - 1;
       while (strrchr (buf_str, '/') == (buf_str + tmp))
@@ -504,7 +505,7 @@
           buf_str++;
         }
       link_name = xstrndup (tmp_str, strlen (tmp_str));
-      free (buf_str);
+      free (base_str);
     }
   /*  User specified a name, so check it and convert  */
   else

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]