locking/posix.c: Fixed double-free nasty crash bug found by insure.
authorJeremy Allison <jra@samba.org>
Mon, 1 May 2000 19:43:50 +0000 (19:43 +0000)
committerJeremy Allison <jra@samba.org>
Mon, 1 May 2000 19:43:50 +0000 (19:43 +0000)
utils/make_smbcodepage.c:
utils/make_unicodemap.c: Insure 'make install' fixes.
Jeremy.
(This used to be commit 3b25f7368be3877e9ad27498bc9451ec88d4b07f)

source3/locking/posix.c
source3/utils/make_smbcodepage.c
source3/utils/make_unicodemap.c

index d6eaad89c14585e190d1c2db39eac7dae069c1e2..7cada20ac3cb4a90ff16d12df9b382eb7eba7ef9 100644 (file)
@@ -246,9 +246,6 @@ int fd_close_posix(struct connection_struct *conn, files_struct *fsp)
                        }
                }
 
-               if (fd_array)
-                       free((char *)fd_array);
-
                /*
                 * Delete all fd's stored in the tdb
                 * for this dev/inode pair.
index f0b68a7baea9b37f7c9c250c89f2339e0888a0fc..1bd3edc2631eeea52dd7805ce711e8a5166c4430 100644 (file)
@@ -167,6 +167,7 @@ static int do_compile(int codepage, char *input_file, char *output_file)
   FILE *fp = NULL;
   size_t size = 0;
   char *buf = NULL;
+  char *orig_buf = NULL;
   char output_buf[CODEPAGE_HEADER_SIZE + 4 * MAXCODEPAGELINES];
   int num_lines = 0;
   int i = 0;
@@ -223,6 +224,8 @@ The maximum size I will believe is 100k.\n", prog_name, size);
 
   num_lines = clean_data( &buf, &size);
 
+  orig_buf = buf; /* Save for free(). */
+
   /* There can be a maximum of MAXCODEPAGELINES lines. */
   if(num_lines > MAXCODEPAGELINES)
   {
@@ -300,6 +303,7 @@ definition file. File %s has %d.\n", prog_name, MAXCODEPAGELINES, input_file, nu
 
   fclose(fp);
 
+  free(orig_buf);
   return 0;
 }
 
index 76c49361bec12ed6b8d99b062fe66678dceb7766..ff9bb19b6fe8f7402a3dc08146b8ab9ea47fcadb 100644 (file)
@@ -139,6 +139,7 @@ static int do_compile(const char *codepage, const char *input_file, const char *
   size_t size = 0;
   size_t offset = 0;
   char *buf = NULL;
+  char *orig_buf = NULL;
   char *output_buf = NULL;
   uint16 cp_to_ucs2[65536];
   uint16 ucs2_to_cp[65536];
@@ -186,6 +187,8 @@ static int do_compile(const char *codepage, const char *input_file, const char *
 
   num_lines = clean_data( &buf, &size);
 
+  orig_buf = buf; /* Store for free(). */
+
   /*
    * Initialize the output data.
    */
@@ -285,7 +288,9 @@ static int do_compile(const char *codepage, const char *input_file, const char *
   }  
 
   fclose(fp);
-
+  
+  free(orig_buf);
+  free(output_buf);
   return 0;
 }