Przeglądaj źródła

bug 214
Fix pthread mutex not unlocked in error path

(Logical change 1.122)


git-svn-id: http://svn.fedorahosted.org/svn/corosync/trunk@434 fd59a12c-fef9-0310-b244-a6a79926bd2f

Steven Dake 21 lat temu
rodzic
commit
b6306c29d5
1 zmienionych plików z 7 dodań i 2 usunięć
  1. 7 2
      lib/util.c

+ 7 - 2
lib/util.c

@@ -437,19 +437,24 @@ saHandleInstanceGet (
 	unsigned int handle,
 	void **instance)
 { 
+	SaErrorT error = SA_OK;
+
 	pthread_mutex_lock (&handleDatabase->mutex);
 
 	if (handle >= handleDatabase->handleCount) {
-		return (SA_ERR_BAD_HANDLE);
+		error = SA_ERR_BAD_HANDLE;
+		goto error_exit;
 	}
 	if (handleDatabase->handles[handle].state != SA_HANDLE_STATE_ACTIVE) {
-		return (SA_ERR_BAD_HANDLE);
+		error = SA_ERR_BAD_HANDLE;
+		goto error_exit;
 	}
 
 	*instance = handleDatabase->handles[handle].instance;
 
 	handleDatabase->handles[handle].refCount += 1;
 
+error_exit:
 	pthread_mutex_unlock (&handleDatabase->mutex);
 
 	return (SA_OK);