[llvm-bugs] [Bug 32234] New: Analyzer: "Potential memory leak" warning from std::unique_ptr move-only assignment operator

via llvm-bugs llvm-bugs at lists.llvm.org
Fri Mar 10 14:38:21 PST 2017


https://bugs.llvm.org/show_bug.cgi?id=32234

            Bug ID: 32234
           Summary: Analyzer: "Potential memory leak" warning from
                    std::unique_ptr move-only assignment operator
           Product: clang
           Version: unspecified
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Static Analyzer
          Assignee: kremenek at apple.com
          Reporter: marshallk at google.com
                CC: llvm-bugs at lists.llvm.org

LLVM version: clang version 5.0.0 (trunk 296321)
Platform: Linux; target: Linux
Code:
https://cs.chromium.org/chromium/src/dbus/values_util.cc?rcl=094b5e38f83ceebb408911139f194dd3705e54be&l=199

[1375/20604] CXX obj/dbus/dbus/values_util.o
In file included from ../../dbus/values_util.cc:5:
In file included from ../../dbus/values_util.h:10:
In file included from
../../build/linux/debian_wheezy_amd64-sysroot/usr/lib/gcc/x86_64-linux-gnu/4.6/../../../../include/c++/4.6/memory:85:
../../build/linux/debian_wheezy_amd64-sysroot/usr/lib/gcc/x86_64-linux-gnu/4.6/../../../../include/c++/4.6/bits/unique_ptr.h:190:4:
warning: Potential memory leak
          return *this;
          ^
../../dbus/values_util.cc:94:3: note: Control jumps to 'case STRUCT:'  at line
197
  switch (reader->GetDataType()) {
  ^
../../dbus/values_util.cc:199:11: note: Assuming the condition is true
      if (reader->PopStruct(&sub_reader)) {
          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../../dbus/values_util.cc:199:7: note: Taking true branch
      if (reader->PopStruct(&sub_reader)) {
      ^
../../dbus/values_util.cc:200:53: note: Memory is allocated
        std::unique_ptr<base::ListValue> list_value(new base::ListValue);
                                                    ^~~~~~~~~~~~~~~~~~~
../../dbus/values_util.cc:201:9: note: Taking true branch
        if (PopListElements(&sub_reader, list_value.get()))
        ^
../../dbus/values_util.cc:202:11: note: Calling 'unique_ptr::operator='
          result = std::move(list_value);
          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../../build/linux/debian_wheezy_amd64-sysroot/usr/lib/gcc/x86_64-linux-gnu/4.6/../../../../include/c++/4.6/bits/unique_ptr.h:190:4:
note: Potential memory leak
          return *this;
          ^
1 warning generated.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20170310/4cd63583/attachment.html>


More information about the llvm-bugs mailing list