Index: src/podofo/doc/PdfImage.cpp
===================================================================
--- src/podofo/doc/PdfImage.cpp	(revision 1999)
+++ src/podofo/doc/PdfImage.cpp	(working copy)
@@ -601,15 +601,15 @@
             uint16 * rgbBlue;
             TIFFGetField(hInTiffHandle, TIFFTAG_COLORMAP, &rgbRed, &rgbGreen, &rgbBlue);
             
-            char *datap = new char[numColors*3];
+            vector<char> data(numColors * 3);
             
             for ( int clr = 0; clr < numColors; clr++ )
             {
-                datap[3*clr+0] = rgbRed[clr]/257;
-                datap[3*clr+1] = rgbGreen[clr]/257;
-                datap[3*clr+2] = rgbBlue[clr]/257;
+                data[3*clr+0] = rgbRed[clr]/257;
+                data[3*clr+1] = rgbGreen[clr]/257;
+                data[3*clr+2] = rgbBlue[clr]/257;
             }
-            PdfMemoryInputStream stream( datap, numColors*3 );
+            PdfMemoryInputStream stream( data.data(), data.size() );
             
             // Create a colorspace object
             PdfObject* pIdxObject = this->GetObject()->GetOwner()->CreateObject();
@@ -622,8 +622,6 @@
             array.push_back( static_cast<pdf_int64>(numColors-1) );
             array.push_back( pIdxObject->Reference() );
             this->GetObject()->GetDictionary().AddKey( PdfName("ColorSpace"), array );
-            
-            delete[] datap;
         }
             break;
             
@@ -634,13 +632,7 @@
     }
     
     int32 scanlineSize = TIFFScanlineSize(hInTiffHandle);
-    long bufferSize = scanlineSize * height;
-    char *buffer = new char[bufferSize];
-    if( !buffer )
-    {
-        TIFFClose(hInTiffHandle);
-        PODOFO_RAISE_ERROR( ePdfError_OutOfMemory );
-    }
+    vector<char> buffer(scanlineSize * height);
     
     for(row = 0; row < height; row++)
     {
@@ -653,7 +645,7 @@
         }
     }
     
-    PdfMemoryInputStream stream(buffer, bufferSize);
+    PdfMemoryInputStream stream(buffer.data(), buffer.size());
     
     SetImageData(static_cast<unsigned int>(width),
                  static_cast<unsigned int>(height),
@@ -660,8 +652,6 @@
                  static_cast<unsigned int>(bitsPerSample),
                  &stream);
     
-    delete[] buffer;
-    
     TIFFClose(hInTiffHandle);
 }
  
