Bug 141402

Summary: Check for self-assignment in Length::operator=(const Length&)
Product: WebKit Reporter: Chris Dumez <cdumez>
Component: CSSAssignee: Chris Dumez <cdumez>
Status: RESOLVED FIXED    
Severity: Normal CC: andersca, commit-queue, ddkilzer, kling, koivisto, simon.fraser
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
Patch
none
Patch none

Description Chris Dumez 2015-02-09 14:31:55 PST
Check for self-assignment in Length::operator=(const Length&) as calling memset() with the same source and destination addresses has undefined behavior.
Comment 1 Chris Dumez 2015-02-09 14:34:17 PST
Created attachment 246292 [details]
Patch
Comment 2 Chris Dumez 2015-02-09 14:40:37 PST
Created attachment 246293 [details]
Patch
Comment 3 WebKit Commit Bot 2015-02-09 17:17:48 PST
Comment on attachment 246293 [details]
Patch

Clearing flags on attachment: 246293

Committed r179860: <http://trac.webkit.org/changeset/179860>
Comment 4 WebKit Commit Bot 2015-02-09 17:17:52 PST
All reviewed patches have been landed.  Closing bug.
Comment 5 David Kilzer (:ddkilzer) 2015-02-10 09:18:06 PST
(In reply to comment #0)
> Check for self-assignment in Length::operator=(const Length&) as calling
> memset() with the same source and destination addresses has undefined
> behavior.

On Darwin platforms (iOS, OS X), the undefined behavior has been well-defined as being identical to memmove().  (However, that's not true on other platforms, so it's still a good idea to fix this.)
Comment 6 Chris Dumez 2015-02-10 09:49:00 PST
(In reply to comment #5)
> (In reply to comment #0)
> > Check for self-assignment in Length::operator=(const Length&) as calling
> > memset() with the same source and destination addresses has undefined
> > behavior.
> 
> On Darwin platforms (iOS, OS X), the undefined behavior has been
> well-defined as being identical to memmove().  (However, that's not true on
> other platforms, so it's still a good idea to fix this.)

Oh, I did not know that. If I do a "man memcpy" on my Mac, it says "If dst and src overlap, behavior is undefined".