Skip to content

Commit ad9b640

Browse files
authoredDec 3, 2024··
fix: check if m_pCodec is initialized (#9)
1 parent 46f252f commit ad9b640

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed
 

‎extension.cpp

+11-3
Original file line numberDiff line numberDiff line change
@@ -805,11 +805,19 @@ void CVoice::HandleVoiceData()
805805
unsigned char aFinal[PacketSize];
806806
int FinalSize = 0;
807807

808-
FinalSize = celt_encode(m_pCodec, aBuffer, SamplesPerFrame, aFinal, sizeof(aFinal));
808+
if (m_pCodec)
809+
{
810+
FinalSize = celt_encode(m_pCodec, aBuffer, SamplesPerFrame, aFinal, sizeof(aFinal));
809811

810-
if(FinalSize <= 0)
812+
if(FinalSize <= 0)
813+
{
814+
smutils->LogError(myself, "Compress returned %d\n", FinalSize);
815+
return;
816+
}
817+
}
818+
else
811819
{
812-
smutils->LogError(myself, "Compress returned %d\n", FinalSize);
820+
smutils->LogError(myself, "CELT codec is null\n");
813821
return;
814822
}
815823

0 commit comments

Comments
 (0)
Please sign in to comment.