Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 6f8e3362 authored by Greg Kaiser's avatar Greg Kaiser
Browse files

AMRWB_E_SAMPLE: Fix resource leaks in error cases

We also avoid a pontential call to dlclose(NULL) which was
possible in the previous code.

Note the leaks aren't really consequential since this is a
standalone sample.  But by putting in simple fixes for these,
we reduce the noise when using static analysis to find leaks
in Android code.

Test: TreeHugger

Change-Id: I3f69e410ecf611dcb60e4f58aae27801b2141e4d
parent c0884f53
Loading
Loading
Loading
Loading
+8 −4
Original line number Diff line number Diff line
@@ -134,14 +134,16 @@ int encode(
	if(handle == 0)
	{
		printf("open dll error......");
		return -1;
		ret = -1;
		goto safe_exit;
	}

	pfunc = dlsym(handle, "voGetAMRWBEncAPI");
	if(pfunc == 0)
	{
		printf("open function error......");
		return -1;
		ret = -1;
		goto safe_exit;
	}

	pGetAPI = (VOGETAUDIOENCAPI)pfunc;
@@ -150,7 +152,8 @@ int encode(
	if(returnCode)
	{
		printf("get APIs error......");
		return -1;
		ret = -1;
		goto safe_exit;
	}
#else
	ret = voGetAMRWBEncAPI(&AudioAPI);
@@ -253,6 +256,7 @@ safe_exit:
		fclose(fdst);

#ifdef LINUX
	if (handle)
		dlclose(handle);
#endif