]> granicus.if.org Git - imagemagick/commitdiff
(no commit message)
authorcristy <urban-warrior@git.imagemagick.org>
Sun, 30 Mar 2014 23:27:24 +0000 (23:27 +0000)
committercristy <urban-warrior@git.imagemagick.org>
Sun, 30 Mar 2014 23:27:24 +0000 (23:27 +0000)
MagickCore/matrix.c

index 5efe945ed627d3be7c8362321906eeb0f5953b3e..fbb7ecb91f6c74f77a944ee7260933d503d6b553 100644 (file)
@@ -144,8 +144,12 @@ static inline MagickOffsetType WriteMatrixElements(
     count;
 
 #if !defined(MAGICKCORE_HAVE_PWRITE)
+  LockSemaphoreInfo(matrix_info->semaphore);
   if (lseek(matrix_info->file,offset,SEEK_SET) < 0)
-    return((MagickOffsetType) -1);
+    {
+      UnlockSemaphoreInfo(matrix_info->semaphore);
+      return((MagickOffsetType) -1);
+    }
 #endif
   count=0;
   for (i=0; i < (MagickOffsetType) length; i+=count)
@@ -164,6 +168,9 @@ static inline MagickOffsetType WriteMatrixElements(
           break;
       }
   }
+#if !defined(MAGICKCORE_HAVE_PWRITE)
+  UnlockSemaphoreInfo(matrix_info->semaphore);
+#endif
   return(i);
 }
 
@@ -680,8 +687,12 @@ static inline MagickOffsetType ReadMatrixElements(
     count;
 
 #if !defined(MAGICKCORE_HAVE_PREAD)
+  LockSemaphoreInfo(matrix_info->semaphore);
   if (lseek(matrix_info->file,offset,SEEK_SET) < 0)
-    return((MagickOffsetType) -1);
+    {
+      UnlockSemaphoreInfo(matrix_info->semaphore);
+      return((MagickOffsetType) -1);
+    }
 #endif
   count=0;
   for (i=0; i < (MagickOffsetType) length; i+=count)
@@ -700,6 +711,9 @@ static inline MagickOffsetType ReadMatrixElements(
           break;
       }
   }
+#if !defined(MAGICKCORE_HAVE_PREAD)
+  UnlockSemaphoreInfo(matrix_info->semaphore);
+#endif
   return(i);
 }
 
@@ -720,10 +734,8 @@ MagickExport MagickBooleanType GetMatrixElement(const MatrixInfo *matrix_info,
         matrix_info->stride,matrix_info->stride);
       return(MagickTrue);
     }
-  LockSemaphoreInfo(matrix_info->semaphore);
   count=ReadMatrixElements(matrix_info,i*matrix_info->stride,
     matrix_info->stride,value);
-  UnlockSemaphoreInfo(matrix_info->semaphore);
   if (count != (MagickOffsetType) matrix_info->stride)
     return(MagickFalse);
   return(MagickTrue);
@@ -995,10 +1007,8 @@ MagickExport MagickBooleanType SetMatrixElement(const MatrixInfo *matrix_info,
         matrix_info->stride,value,matrix_info->stride);
       return(MagickTrue);
     }
-  LockSemaphoreInfo(matrix_info->semaphore);
   count=WriteMatrixElements(matrix_info,i*matrix_info->stride,
     matrix_info->stride,value);
-  UnlockSemaphoreInfo(matrix_info->semaphore);
   if (count != (MagickOffsetType) matrix_info->stride)
     return(MagickFalse);
   return(MagickTrue);