Fix SkTArray operator= to work with self assignment
BUG=skia:
Change-Id: I2a403a7ccbb87a030757f3e57d2ea53503f72512
Reviewed-on: https://skia-review.googlesource.com/10012
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Greg Daniel <egdaniel@google.com>
diff --git a/include/private/SkTArray.h b/include/private/SkTArray.h
index fdf96c8..4b700d2 100644
--- a/include/private/SkTArray.h
+++ b/include/private/SkTArray.h
@@ -59,6 +59,9 @@
}
SkTArray& operator=(const SkTArray& that) {
+ if (this == &that) {
+ return *this;
+ }
for (int i = 0; i < fCount; ++i) {
fItemArray[i].~T();
}
@@ -69,6 +72,9 @@
return *this;
}
SkTArray& operator=(SkTArray&& that) {
+ if (this == &that) {
+ return *this;
+ }
for (int i = 0; i < fCount; ++i) {
fItemArray[i].~T();
}