]> git.imager.perl.org - imager.git/commitdiff
- loading filter DLLs/DSOs had an off-by-one error allocating a buffer
authorTony Cook <tony@develop=help.com>
Thu, 4 Aug 2005 06:24:03 +0000 (06:24 +0000)
committerTony Cook <tony@develop=help.com>
Thu, 4 Aug 2005 06:24:03 +0000 (06:24 +0000)
  for the filename of the library (does anyone use this functionality?)

Changes
dynaload.c

diff --git a/Changes b/Changes
index 8ff5510b6dd3a3f05c7bece39599711f0d8d0dc4..48c88c092a2a02b7e14c828c9d6af9dd4f5e462d 100644 (file)
--- a/Changes
+++ b/Changes
@@ -1118,6 +1118,8 @@ Revision history for Perl extension Imager.
   add them to the method index.
 - added tiff_bitspersample and tiff_photometric tags to tiff images
   when read
+- loading filter DLLs/DSOs had an off-by-one error allocating a buffer
+  for the filename of the library (does anyone use this functionality?)
 
 =================================================================
 
index fbc55c71e891dd85bd40fff3b5b6df14ada96457..1d308fd721f2cb1cd9d5ce71657caa03f215dd50 100644 (file)
@@ -57,11 +57,14 @@ DSO_open(char* file,char** evalstring) {
   mm_log( (1,"Call ok.\n") ); 
  
   if ( (shl_findsym(&tt_handle, I_FUNCTION_LIST ,TYPE_UNDEFINED,(func_ptr*)&function_list))) return NULL; 
-  if ( (dso_handle=(DSO_handle*)malloc(sizeof(DSO_handle))) == NULL) return NULL;
+  if ( (dso_handle=(DSO_handle*)malloc(sizeof(DSO_handle))) == NULL) /* checked 17jul05 tonyc */
+    return NULL;
 
   dso_handle->handle=tt_handle; /* needed to close again */
   dso_handle->function_list=function_list;
-  if ( (dso_handle->filename=(char*)malloc(strlen(file))) == NULL) { free(dso_handle); return NULL; }
+  if ( (dso_handle->filename=(char*)malloc(strlen(file)+1)) == NULL) { /* checked 17jul05 tonyc */
+    free(dso_handle); return NULL;
+  }
   strcpy(dso_handle->filename,file);
 
   mm_log((1,"DSO_open <- (0x%X)\n",dso_handle));
@@ -111,14 +114,18 @@ DSO_open(char *file, char **evalstring) {
     FreeLibrary(d_handle);
     return NULL;
   }
-  if ( (dso_handle = (DSO_handle*)malloc(sizeof(DSO_handle))) == NULL) {
+  if ( (dso_handle = (DSO_handle*)malloc(sizeof(DSO_handle))) == NULL) { /* checked 17jul05 tonyc */
     mm_log( (1, "DSO_Open: out of memory\n") );
     FreeLibrary(d_handle);
     return NULL;
   }
   dso_handle->handle=d_handle; /* needed to close again */
   dso_handle->function_list=function_list;
-  if ( (dso_handle->filename=(char*)malloc(strlen(file))) == NULL) { free(dso_handle); FreeLibrary(d_handle); return NULL; }
+  if ( (dso_handle->filename=(char*)malloc(strlen(file)+1)) == NULL) { /* checked 17jul05 tonyc */
+    free(dso_handle);
+    FreeLibrary(d_handle); 
+    return NULL; 
+  }
   strcpy(dso_handle->filename,file);
 
   mm_log( (1,"DSO_open <- 0x%X\n",dso_handle) );
@@ -287,11 +294,15 @@ DSO_open(char* file,char** evalstring) {
     return NULL;
   }
   
-  if ( (dso_handle=(DSO_handle*)malloc(sizeof(DSO_handle))) == NULL) return NULL;
+  if ( (dso_handle=(DSO_handle*)malloc(sizeof(DSO_handle))) == NULL) /* checked 17jul05 tonyc */
+    return NULL;
   
   dso_handle->handle=d_handle; /* needed to close again */
   dso_handle->function_list=function_list;
-  if ( (dso_handle->filename=(char*)malloc(strlen(file))) == NULL) { free(dso_handle); return NULL; }
+  if ( (dso_handle->filename=(char*)malloc(strlen(file)+1)) == NULL) { /* checked 17jul05 tonyc */
+    free(dso_handle); 
+    return NULL;
+  }
   strcpy(dso_handle->filename,file);
 
   mm_log( (1,"DSO_open <- 0x%X\n",dso_handle) );