Skip to content

Latest commit

 

History

History
20 lines (17 loc) · 908 Bytes

c26405.md

File metadata and controls

20 lines (17 loc) · 908 Bytes
description title ms.date ms.topic f1_keywords helpviewer_keywords ms.assetid
Learn more about: C26405 DONT_ASSIGN_TO_VALID
C26405
07/21/2017
conceptual
C26405
C26405
2034d961-3ec5-4184-bbef-aa792e4c03c0

C26405 DONT_ASSIGN_TO_VALID

If an owner pointer already points to a valid memory buffer, it must not be assigned to another value without releasing its current resource first. Such assignment may lead to a resource leak even if the resource address is copied into some raw pointer (because raw pointers shouldn’t release resources). For more information, see the C++ Core Guidelines.

Example 1: Overwriting an owner in a loop

gsl::owner<Shape*> shape = nullptr;
while (shape = NextShape()) // C26405
    Process(shape) ? delete shape : 0;