Skip to content

Commit a7bc1e2

Browse files
author
Dogancan Ozturk
committed
bug fix nullptr uninitialize
1 parent e167ef1 commit a7bc1e2

File tree

6 files changed

+18
-9
lines changed

6 files changed

+18
-9
lines changed

Examples/CrossPlatformTest/CrossPlatformTest.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
</Content>
2424
<Content Include="openh264-2.4.1-win64.dll">
2525
<PackagePath>\lib\$(TargetFramework)</PackagePath>
26-
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
26+
<CopyToOutputDirectory>Never</CopyToOutputDirectory>
2727
<Pack>true</Pack>
2828
</Content>
2929
</ItemGroup>
0 Bytes
Binary file not shown.

H264Sharp/H264Decoder.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,15 +56,15 @@ private void LoadDecoder(string ciscoDllPath)
5656
// Success
5757
break;
5858
case 1:
59-
throw new DllNotFoundException($"Failed to load the decoder library: {ciscoDllPath}");
59+
throw new DllNotFoundException($"Failed to load the cisco library: {ciscoDllPath}");
6060
case 2:
6161
throw new EntryPointNotFoundException("Failed to load WelsCreateDecoder function");
6262
case 3:
6363
throw new EntryPointNotFoundException("Failed to load WelsDestroyDecoder function");
6464
case 4:
6565
throw new InvalidOperationException("Failed to create decoder instance");
6666
default:
67-
throw new Exception($"Unknown error occurred while loading decoder: {result}");
67+
throw new Exception($"Unknown error occurred code: {result}");
6868
}
6969
}
7070

H264Sharp/H264Encoder.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,15 +51,15 @@ private void LoadEncoder(string ciscoDllPath)
5151
// Success
5252
break;
5353
case 1:
54-
throw new DllNotFoundException($"Failed to load the encoder library: {ciscoDllPath}");
54+
throw new DllNotFoundException($"Failed to load the cisco library: {ciscoDllPath}");
5555
case 2:
5656
throw new EntryPointNotFoundException("Failed to load WelsCreateSVCEncoder function");
5757
case 3:
5858
throw new EntryPointNotFoundException("Failed to load WelsDestroySVCEncoder function");
5959
case 4:
6060
throw new InvalidOperationException("Failed to create encoder instance");
6161
default:
62-
throw new Exception($"Unknown error occurred while loading encoder: {result}");
62+
throw new Exception($"Unknown error occurred code: {result}");
6363
}
6464
}
6565

H264SharpNative/Decoder.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -339,8 +339,13 @@ namespace H264Sharp {
339339
Decoder::~Decoder()
340340
{
341341
FreeAllignAlloc(innerBuffer);
342-
decoder->Uninitialize();
343-
DestroyDecoderFunc(decoder);
342+
343+
if(decoder !=nullptr)
344+
{
345+
decoder->Uninitialize();
346+
DestroyDecoderFunc(decoder);
347+
}
348+
344349

345350
if (libraryHandle != nullptr) {
346351
#ifdef _WIN32

H264SharpNative/Encoder.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -693,8 +693,12 @@ namespace H264Sharp {
693693

694694
Encoder::~Encoder()
695695
{
696-
encoder->Uninitialize();
697-
DestroyEncoderFunc(encoder);
696+
if (encoder != nullptr)
697+
{
698+
encoder->Uninitialize();
699+
DestroyEncoderFunc(encoder);
700+
}
701+
698702

699703
FreeAllignAlloc(innerBuffer);
700704
for (auto& it : efm)

0 commit comments

Comments
 (0)