소스 검색

libobs: Fix missing mutex unlock from 26dbe54

Richard Stanway 6 년 전
부모
커밋
3ddfc55e46
1개의 변경된 파일10개의 추가작업 그리고 9개의 파일을 삭제
  1. 10 9
      libobs/util/config-file.c

+ 10 - 9
libobs/util/config-file.c

@@ -359,6 +359,7 @@ int config_save(config_t *config)
 	FILE *f;
 	struct dstr str, tmp;
 	size_t i, j;
+	int ret = CONFIG_ERROR;
 
 	if (!config)
 		return CONFIG_ERROR;
@@ -405,15 +406,15 @@ int config_save(config_t *config)
 	}
 
 #ifdef _WIN32
-	if (fwrite("\xEF\xBB\xBF", 3, 1, f) != 1) {
-		fclose(f);
-		return CONFIG_ERROR;
-	}
+	if (fwrite("\xEF\xBB\xBF", 3, 1, f) != 1)
+		goto cleanup;
 #endif
-	if (fwrite(str.array, str.len, 1, f) != 1) {
-		fclose(f);
-		return CONFIG_ERROR;
-	}
+	if (fwrite(str.array, str.len, 1, f) != 1)
+		goto cleanup;
+
+	ret = CONFIG_SUCCESS;
+
+cleanup:
 	fclose(f);
 
 	pthread_mutex_unlock(&config->mutex);
@@ -421,7 +422,7 @@ int config_save(config_t *config)
 	dstr_free(&tmp);
 	dstr_free(&str);
 
-	return CONFIG_SUCCESS;
+	return ret;
 }
 
 int config_save_safe(config_t *config, const char *temp_ext,