Bug Summary

File:root/firefox-clang/obj-x86_64-pc-linux-gnu/third_party/libwebrtc/modules/audio_coding/g722_c_gn/./../../../../../../third_party/libwebrtc/modules/audio_coding/codecs/g722/g722_interface.c
Warning:line 55, column 33
Result of 'malloc' is converted to a pointer of type 'G722DecInst', which is incompatible with sizeof operand type 'G722DecoderState'

Annotated Source Code

Press '?' to see keyboard shortcuts

clang -cc1 -cc1 -triple x86_64-pc-linux-gnu -O2 -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name Unified_c_g722_c_gn0.c -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -analyzer-config-compatibility-mode=true -mrelocation-model pic -pic-level 2 -fhalf-no-semantic-interposition -mframe-pointer=all -relaxed-aliasing -ffp-contract=off -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fdebug-compilation-dir=/root/firefox-clang/obj-x86_64-pc-linux-gnu/third_party/libwebrtc/modules/audio_coding/g722_c_gn -fcoverage-compilation-dir=/root/firefox-clang/obj-x86_64-pc-linux-gnu/third_party/libwebrtc/modules/audio_coding/g722_c_gn -resource-dir /usr/lib/llvm-23/lib/clang/23 -include /root/firefox-clang/config/gcc_hidden.h -include /root/firefox-clang/obj-x86_64-pc-linux-gnu/mozilla-config.h -I /root/firefox-clang/obj-x86_64-pc-linux-gnu/dist/system_wrappers -U _FORTIFY_SOURCE -D _FORTIFY_SOURCE=2 -D DEBUG=1 -D ABSL_ALLOCATOR_NOTHROW=1 -D PROTOBUF_ENABLE_DEBUG_LOGGING_MAY_LEAK_PII=0 -D RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY -D RTC_ENABLE_VP9 -D WEBRTC_DEPRECATE_PLAN_B -D WEBRTC_ENABLE_PROTOBUF=0 -D WEBRTC_ENCODER_PSNR_STATS -D WEBRTC_LIBRARY_IMPL -D WEBRTC_MOZILLA_BUILD -D WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS=0 -D WEBRTC_STRICT_FIELD_TRIALS=0 -D DYNAMIC_ANNOTATIONS_ENABLED=1 -D USE_AURA=1 -D USE_GLIB=1 -D USE_OZONE=1 -D USE_UDEV -D WEBRTC_LINUX -D WEBRTC_POSIX -D _FILE_OFFSET_BITS=64 -D _LARGEFILE64_SOURCE -D _LARGEFILE_SOURCE -D __STDC_CONSTANT_MACROS -D __STDC_FORMAT_MACROS -D WEBRTC_ENABLE_AVX2 -D _DEBUG -D _GNU_SOURCE -D MOZ_HAS_MOZGLUE -D MOZILLA_INTERNAL_API -D IMPL_LIBXUL -D MOZ_SUPPORT_LEAKCHECKING -D STATIC_EXPORTABLE_JS_API -I /root/firefox-clang/third_party/libwebrtc/modules/audio_coding/g722_c_gn -I /root/firefox-clang/obj-x86_64-pc-linux-gnu/third_party/libwebrtc/modules/audio_coding/g722_c_gn -I /root/firefox-clang/obj-x86_64-pc-linux-gnu/dist/include/libwebrtc_overrides -I /root/firefox-clang/obj-x86_64-pc-linux-gnu/ipc/ipdl/_ipdlheaders -I /root/firefox-clang/obj-x86_64-pc-linux-gnu/third_party/libwebrtc/gen -I /root/firefox-clang/ipc/chromium/src -I /root/firefox-clang/third_party/abseil-cpp -I /root/firefox-clang/third_party/libwebrtc -I /root/firefox-clang/tools/profiler/public -I /root/firefox-clang/obj-x86_64-pc-linux-gnu/dist/include -D MOZILLA_CLIENT -internal-isystem /usr/lib/llvm-23/lib/clang/23/include -internal-isystem /usr/local/include -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/16/../../../../x86_64-linux-gnu/include -internal-externc-isystem /usr/include/x86_64-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wno-error=tautological-type-limit-compare -Wno-range-loop-analysis -Wno-error=deprecated-declarations -Wno-error=array-bounds -Wno-error=free-nonheap-object -Wno-error=atomic-alignment -Wno-error=deprecated-builtins -Wno-psabi -Wno-error=builtin-macro-redefined -Wno-unknown-warning-option -Wno-character-conversion -ferror-limit 19 -fstrict-flex-arrays=1 -stack-protector 2 -fstack-clash-protection -ftrivial-auto-var-init=pattern -fgnuc-version=4.2.1 -fskip-odr-check-in-gmf -fdiagnostics-absolute-paths -vectorize-loops -vectorize-slp -analyzer-checker optin.performance.Padding -analyzer-output=html -analyzer-config stable-report-filename=true -mllvm -dwarf-linkage-names=Abstract -faddrsig -fdwarf2-cfi-asm -o /tmp/scan-build-2026-09-01-224014-2642839-1 -x c Unified_c_g722_c_gn0.c
1/*
2 * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved.
3 *
4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
9 */
10
11#include "modules/audio_coding/codecs/g722/g722_interface.h"
12
13#include <stdlib.h>
14#include <string.h>
15
16#include "modules/third_party/g722/g722_enc_dec.h"
17
18int16_t WebRtcG722_CreateEncoder(G722EncInst** G722enc_inst) {
19 *G722enc_inst = (G722EncInst*)malloc(sizeof(G722EncoderState));
20 if (*G722enc_inst != NULL((void*)0)) {
21 return (0);
22 } else {
23 return (-1);
24 }
25}
26
27int16_t WebRtcG722_EncoderInit(G722EncInst* G722enc_inst) {
28 // Create and/or reset the G.722 encoder
29 // Bitrate 64 kbps and wideband mode (2)
30 G722enc_inst = (G722EncInst*)WebRtc_g722_encode_init(
31 (G722EncoderState*)G722enc_inst, 64000, 2);
32 if (G722enc_inst == NULL((void*)0)) {
33 return -1;
34 } else {
35 return 0;
36 }
37}
38
39int WebRtcG722_FreeEncoder(G722EncInst* G722enc_inst) {
40 // Free encoder memory
41 return WebRtc_g722_encode_release((G722EncoderState*)G722enc_inst);
42}
43
44size_t WebRtcG722_Encode(G722EncInst* G722enc_inst,
45 const int16_t* speechIn,
46 size_t len,
47 uint8_t* encoded) {
48 unsigned char* codechar = (unsigned char*)encoded;
49 // Encode the input speech vector
50 return WebRtc_g722_encode((G722EncoderState*)G722enc_inst, codechar, speechIn,
51 len);
52}
53
54int16_t WebRtcG722_CreateDecoder(G722DecInst** G722dec_inst) {
55 *G722dec_inst = (G722DecInst*)malloc(sizeof(G722DecoderState));
Result of 'malloc' is converted to a pointer of type 'G722DecInst', which is incompatible with sizeof operand type 'G722DecoderState'
56 if (*G722dec_inst != NULL((void*)0)) {
57 return (0);
58 } else {
59 return (-1);
60 }
61}
62
63void WebRtcG722_DecoderInit(G722DecInst* inst) {
64 // Create and/or reset the G.722 decoder
65 // Bitrate 64 kbps and wideband mode (2)
66 WebRtc_g722_decode_init((G722DecoderState*)inst, 64000, 2);
67}
68
69int WebRtcG722_FreeDecoder(G722DecInst* G722dec_inst) {
70 // Free encoder memory
71 return WebRtc_g722_decode_release((G722DecoderState*)G722dec_inst);
72}
73
74size_t WebRtcG722_Decode(G722DecInst* G722dec_inst,
75 const uint8_t* encoded,
76 size_t len,
77 int16_t* decoded,
78 int16_t* speechType) {
79 // Decode the G.722 encoder stream
80 *speechType = G722_WEBRTC_SPEECH1;
81 return WebRtc_g722_decode((G722DecoderState*)G722dec_inst, decoded, encoded,
82 len);
83}
84
85int16_t WebRtcG722_Version(char* versionStr, short len) {
86 // Get version string
87 char version[30] = "2.0.0\n";
88 if (strlen(version) < (unsigned int)len) {
89 strcpy(versionStr, version);
90 return 0;
91 } else {
92 return -1;
93 }
94}