Merge to XFA: Use stdint.h types throughout PDFium.
[pdfium.git] / core / src / fxcodec / codec / fx_codec_png.cpp
index 0ddae7a..8cb24ba 100644 (file)
@@ -50,8 +50,10 @@ static void _png_load_bmp_attribute(png_structp png_ptr, png_infop info_ptr, CFX
         png_timep t = NULL;\r
         png_get_tIME(png_ptr, info_ptr, &t);\r
         if (t) {\r
-            FXSYS_memset32(pAttribute->m_strTime, 0, 20);\r
-            FXSYS_sprintf((FX_LPSTR)pAttribute->m_strTime, "%4d:%2d:%2d %2d:%2d:%2d", t->year, t->month, t->day, t->hour, t->minute, t->second);\r
+            FXSYS_memset32(pAttribute->m_strTime, 0, sizeof(pAttribute->m_strTime));\r
+            FXSYS_snprintf((FX_LPSTR)pAttribute->m_strTime, sizeof(pAttribute->m_strTime), "%4d:%2d:%2d %2d:%2d:%2d",\r
+                           t->year, t->month, t->day, t->hour, t->minute, t->second);\r
+            pAttribute->m_strTime[sizeof(pAttribute->m_strTime) - 1] = 0;\r
             bTime = 1;\r
         }\r
 #endif\r
@@ -67,8 +69,9 @@ static void _png_load_bmp_attribute(png_structp png_ptr, png_infop info_ptr, CFX
             buf = "Time";\r
             if (!FXSYS_memcmp32(buf, text[i].key, FX_MIN(len, FXSYS_strlen(buf)))) {\r
                 if (!bTime) {\r
-                    FXSYS_memset32(pAttribute->m_strTime, 0, 20);\r
-                    FXSYS_memcpy32(pAttribute->m_strTime, text[i].text, text[i].text_length);\r
+                    FXSYS_memset32(pAttribute->m_strTime, 0, sizeof(pAttribute->m_strTime));\r
+                    FXSYS_memcpy32(pAttribute->m_strTime, text[i].text,\r
+                                   FX_MIN(sizeof(pAttribute->m_strTime) - 1, text[i].text_length));\r
                 }\r
             } else {\r
                 buf = "Author";\r
@@ -188,7 +191,7 @@ static void _png_get_row_func(png_structp png_ptr, png_bytep new_row, png_uint_3
 }\r
 void* CCodec_PngModule::Start(void* pModule)\r
 {\r
-    FXPNG_Context* p = (FXPNG_Context*)FX_Alloc(FX_BYTE, sizeof(FXPNG_Context));\r
+    FXPNG_Context* p = (FXPNG_Context*)FX_Alloc(uint8_t, sizeof(FXPNG_Context));\r
     if(p == NULL) {\r
         return NULL;\r
     }\r