Index: src/core/SkFlattenableSerialization.cpp |
diff --git a/src/core/SkFlattenableSerialization.cpp b/src/core/SkFlattenableSerialization.cpp |
index b74c82f051648f77dce5da97b26e21ba53b12e4b..c6bce673f4bedc29c8913d09407d0b57d4a2baf4 100644 |
--- a/src/core/SkFlattenableSerialization.cpp |
+++ b/src/core/SkFlattenableSerialization.cpp |
@@ -9,6 +9,7 @@ |
#include "SkData.h" |
#include "SkFlattenable.h" |
+#include "SkImageFilter.h" |
#include "SkOrderedReadBuffer.h" |
#include "SkOrderedWriteBuffer.h" |
@@ -26,3 +27,27 @@ SkFlattenable* SkDeserializeFlattenable(const void* data, size_t size) { |
SkOrderedReadBuffer buffer(data, size); |
return buffer.readFlattenable(); |
} |
+ |
+bool SkValidateImageFilterRec(SkFlattenable* flattenable) { |
+ if (!flattenable |
+ // This object should always have been sent cross-process, |
+ // so it should always have a factory |
+ || !flattenable->getFactory() |
scroggo
2013/08/21 23:25:27
I'm trying to understand how this could return NUL
sugoi1
2013/08/22 15:41:00
Well, my original thought was that, if someone wou
|
+ // Only SkImageFilter objects are allowed |
+ || !flattenable->isA(SkFlattenable::IMAGE_FILTER)) |
scroggo
2013/08/21 23:25:27
If the unflattening created an SkImageFilter, won'
sugoi1
2013/08/22 15:41:00
How would I know it was wrong to create it ? I hav
scroggo
2013/08/22 17:59:01
My point is that if you read the stream incorrectl
sugoi1
2013/08/22 18:14:53
When this function is called, it verifies that wha
scroggo
2013/08/22 19:10:19
Ah, okay. Thanks for the explanation.
|
+ return false; |
+ |
+ // Check that all the inputs are also SkImageFilter objects |
+ SkImageFilter* filter = static_cast<SkImageFilter*>(flattenable); |
+ int nbInputs = filter->countInputs(); |
+ for (int i = 0; i < nbInputs; ++i) |
+ if (!SkValidateImageFilterRec(filter->getInput(i))) |
+ return false; |
+ |
+ return true; |
+} |
+ |
+SkImageFilter* SkValidateImageFilter(SkFlattenable* flattenable) { |
+ return SkValidateImageFilterRec(flattenable) ? |
+ static_cast<SkImageFilter*>(flattenable) : 0; |
+} |