bug-ddd
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[bug #51281] WhenReadyInfo::WhenReadyInfo() : wrong use of memcpy()


From: Zdenek Sojka
Subject: [bug #51281] WhenReadyInfo::WhenReadyInfo() : wrong use of memcpy()
Date: Tue, 20 Jun 2017 17:15:27 -0400 (EDT)
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.9) Gecko/20100101 Goanna/3.2 Firefox/45.9 PaleMoon/27.3.0

URL:
  <http://savannah.gnu.org/bugs/?51281>

                 Summary: WhenReadyInfo::WhenReadyInfo() : wrong use of
memcpy()
                 Project: DDD
            Submitted by: zsojka
            Submitted on: Tue 20 Jun 2017 09:15:26 PM UTC
                Category: None
                Severity: 3 - Normal
              Item Group: None
                  Status: None
                 Privacy: Public
             Assigned to: None
             Open/Closed: Open
         Discussion Lock: Any
                 Release: 3.3.12-rc2

    _______________________________________________________

Details:

When compiling DDD with a recent gcc (5.4.0 in my case), the following warning
is given:


ddd.C: In constructor 'WhenReadyInfo::WhenReadyInfo(const MString&,
XtCallbackProc, XtPointer, const XmPushButtonCallbackStruct&)':
ddd.C:5825:39: warning: argument to 'sizeof' in 'void* memcpy(void*, const
void*, size_t)' call is the same expression as the destination; did you mean
to dereference it? [-Wsizeof-pointer-memaccess]
      memcpy(cbs.event, c.event, sizeof(cbs.event));


The warning seems to be valid, since the memcpy() parameters are most likely
the same (dst == src), and the size is size_of_pointer.

event is unitialized (its default constructor is used; if applicable)

This patch might trigger the originally intended behavior:

+++ ddd/ddd.C   2017-06-20 23:03:48.946830931 +0200
@@ -5822,7 +5822,7 @@
        }
        else
        {
-           memcpy(cbs.event, c.event, sizeof(cbs.event));
+           memcpy(&event, c.event, sizeof(event));
            cbs.event = &event;
        }
     }






    _______________________________________________________

Reply to this item at:

  <http://savannah.gnu.org/bugs/?51281>

_______________________________________________
  Message sent via/by Savannah
  http://savannah.gnu.org/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]