[x265] [PATCH STABLE] api: prevent recursion in libx265.dll fallback (refs #156)
Steve Borho
steve at borho.org
Tue Aug 18 06:27:13 CEST 2015
# HG changeset patch
# User Steve Borho <steve at borho.org>
# Date 1439871980 -19800
# Tue Aug 18 09:56:20 2015 +0530
# Branch stable
# Node ID 896f8a4615f05e4528a70f0bacaadb2115aedf84
# Parent eb2f4325f7194af215d51b160cd151ceeaa9d916
api: prevent recursion in libx265.dll fallback (refs #156)
If libx265.dll did not contain a requested bitdepth, it would result in infinite
recursion. So we use a global int to break the recursion
diff -r eb2f4325f719 -r 896f8a4615f0 source/encoder/api.cpp
--- a/source/encoder/api.cpp Mon Aug 17 10:27:08 2015 +0530
+++ b/source/encoder/api.cpp Tue Aug 18 09:56:20 2015 +0530
@@ -336,10 +336,17 @@
#define ext ".so"
#endif
+static int g_recursion /* = 0 */;
+
const x265_api* x265_api_get(int bitDepth)
{
if (bitDepth && bitDepth != X265_DEPTH)
{
+ if (g_recursion)
+ return NULL;
+ else
+ g_recursion = 1;
+
#if LINKED_8BIT
if (bitDepth == 8) return x265_8bit::x265_api_get(0);
#endif
@@ -415,6 +422,14 @@
return NULL;
}
+ if (g_recursion)
+ {
+ if (err) *err = X265_API_QUERY_ERR_LIB_NOT_FOUND;
+ return NULL;
+ }
+ else
+ g_recursion = 1;
+
if (err) *err = X265_API_QUERY_ERR_NONE;
if (bitDepth && bitDepth != X265_DEPTH)
More information about the x265-devel
mailing list