bugDDD - Bugs: bug #51281, WhenReadyInfo::WhenReadyInfo() :...

 
 

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

Submitter:  Zdenek Sojka <zsojka>
Submitted:  Tue 20 Jun 2017 09:15:26 PM UTC
 
Category:  None Severity:  3 - Normal
Item Group:  None Status:  Fixed
Privacy:  Public Assigned to:  None
Open/Closed:  Closed Release:  3.3.12
* Mandatory Fields

Add a New Comment (Rich Markup)
   

Comment Type & Canned Response:
       No canned response available

 

Wed 28 Dec 2022 07:11:09 PM UTC, comment #3: 

already fixed

Stefan Eickeler <eickeler>
Project Administrator
Wed 21 Jun 2017 09:10:09 AM UTC, comment #2: 

cbs.event is written to just on the very next line, so if the intention of the memcpy() is to write cbs.event, it can be removed altogether.

Zdenek Sojka <zsojka>
Wed 21 Jun 2017 07:55:00 AM UTC, comment #1: 

The compiler warning is correct but the fix should just require the address-of operator (&) on the first parameter cbs.event.

Ian Kirkham <expl_squirrel>
Project Member
Tue 20 Jun 2017 09:15:26 PM UTC, original submission:  

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;
        }
     }

Zdenek Sojka <zsojka>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by eickeler (Updated the item)
  • -email is unavailable- added by expl_squirrel (Posted a comment)
  • -email is unavailable- added by zsojka (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only logged-in users can vote.

     

     

     

     

    Follow 2 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2022-12-28 eickeler StatusNone Fixed
    2022-12-28 eickeler Open/ClosedOpen Closed

    Back to the top

    Powered by Savane 3.9