Bug 141402 - Check for self-assignment in Length::operator=(const Length&)
Summary: Check for self-assignment in Length::operator=(const Length&)
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: CSS (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Chris Dumez
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-02-09 14:31 PST by Chris Dumez
Modified: 2015-02-10 09:49 PST (History)
6 users (show)

See Also:


Attachments
Patch (1.33 KB, patch)
2015-02-09 14:34 PST, Chris Dumez
no flags Details | Formatted Diff | Diff
Patch (1.33 KB, patch)
2015-02-09 14:40 PST, Chris Dumez
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
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".