Examples of errors detected by the V664 diagnostic
V664. Pointer is dereferenced on the initialization list before its check for null inside the body of a constructor function.
LLVM/Clang
V664 [CWE-476, CERT-EXP34-C] The 'valobj_sp' pointer is being dereferenced on the initialization list before it is verified against null inside the body of the constructor function. Check lines: 211, 212. LibCxx.cpp 211
typedef std::shared_ptr<lldb_private::ValueObject> ValueObjectSP;
lldb_private::formatters::LibCxxMapIteratorSyntheticFrontEnd::
LibCxxMapIteratorSyntheticFrontEnd(lldb::ValueObjectSP valobj_sp)
: SyntheticChildrenFrontEnd(*valobj_sp), m_pair_ptr(), m_pair_sp() {
if (valobj_sp)
Update();
}
Similar errors can be found in some other places:
- V664 [CWE-476, CERT-EXP34-C] The 'valobj_sp' pointer is being dereferenced on the initialization list before it is verified against null inside the body of the constructor function. Check lines: 381, 382. LibCxx.cpp 381
- V664 [CWE-476, CERT-EXP34-C] The 'valobj_sp' pointer is being dereferenced on the initialization list before it is verified against null inside the body of the constructor function. Check lines: 551, 552. LibCxx.cpp 551
- V664 [CWE-476, CERT-EXP34-C] The 'valobj_sp' pointer is being dereferenced on the initialization list before it is verified against null inside the body of the constructor function. Check lines: 635, 636. LibCxx.cpp 635
- And 14 additional diagnostic messages.
FreeCAD
V664 [CWE-476, CERT-EXP34-C] The 'TransformedView' pointer is being dereferenced on the initialization list before it is verified against null inside the body of the constructor function. Check lines: 57, 66. TaskTransformedParameters.cpp 57
TaskTransformedParameters::TaskTransformedParameters(
ViewProviderTransformed *TransformedView, QWidget *parent)
: TaskBox(...., TransformedView->menuName, true, parent) // <=
, proxy(nullptr)
, TransformedView(TransformedView)
, parentTask(nullptr)
, insideMultiTransform(false)
, blockUpdate(false)
{
selectionMode = none;
if (TransformedView) { // <=
Gui::Document* doc = TransformedView->getDocument();
this->attachDocument(doc);
}
....
}
GZDoom
V664 The 'restrict' pointer is being dereferenced on the initialization list before it is verified against null inside the body of the constructor function. Check lines: 1605, 1607. types.cpp 1605
PClassPointer::PClassPointer(PClass *restrict)
: PPointer(restrict->VMType), ClassRestriction(restrict)
{
if (restrict) mDescriptiveName.Format("ClassPointer<%s>",
restrict->TypeName.GetChars());
else mDescriptiveName = "ClassPointer";
loadOp = OP_LP;
storeOp = OP_SP;
Flags |= TYPE_ClassPointer;
mVersion = restrict->VMType->mVersion;
}