check if the encoder factory returned null
authorreed@android.com <reed@android.com@2bbb7eff-a529-9590-31e7-b0007b416f81>
Tue, 7 Jul 2009 21:18:10 +0000 (21:18 +0000)
committerreed@android.com <reed@android.com@2bbb7eff-a529-9590-31e7-b0007b416f81>
Tue, 7 Jul 2009 21:18:10 +0000 (21:18 +0000)
git-svn-id: http://skia.googlecode.com/svn/trunk@255 2bbb7eff-a529-9590-31e7-b0007b416f81

samplecode/SampleEncode.cpp

index 2730ecef60530a596ec4a24b387869dea866e5a8..b09b2ebef60e66766fdf46beeb533d226b4abefe 100644 (file)
@@ -128,7 +128,8 @@ public:
                 remove(path.c_str());
                 
                 SkImageEncoder* codec = SkImageEncoder::Create(gTypes[j]);
-                if (!codec->encodeFile(path.c_str(), fBitmaps[i], 100)) {
+                if (NULL == codec ||
+                        !codec->encodeFile(path.c_str(), fBitmaps[i], 100)) {
                     SkDebugf("------ failed to encode %s\n", path.c_str());
                     remove(path.c_str());   // remove any partial file
                 }