Fix the incorrect filter setting 74/238574/3 accepted/tizen_6.0_unified_hotfix tizen_6.0_hotfix accepted/tizen/6.0/unified/20201030.105807 accepted/tizen/6.0/unified/hotfix/20201102.234826 accepted/tizen/6.0/unified/hotfix/20201103.050049 accepted/tizen/unified/20200717.124643 submit/tizen/20200716.225242 submit/tizen_6.0/20201029.205502 submit/tizen_6.0_hotfix/20201102.192902 submit/tizen_6.0_hotfix/20201103.115102 tizen_6.0.m2_release
authorjiyong.min <jiyong.min@samsung.com>
Wed, 15 Jul 2020 07:38:09 +0000 (16:38 +0900)
committerjiyong.min <jiyong.min@samsung.com>
Thu, 16 Jul 2020 00:02:17 +0000 (09:02 +0900)
  - 'switch~case' in 'png_set_filter()' is dead code.
  'switch~case' updated the value of 'do_filter' using 'filters'.
  However 'do_filter' is overwritten with the 'filters' after few lines.
  So 'switch~case' became dead code, it make filter setting error.

  e.g.
  if 'filters' was #PNG_FILTER_VALUE_NONE(0x00), 'do_filter' updated
  #PNG_FILTER_NONE(0x08) after 'switch~case'. However 'do_filter' is
  overwritten with 'filters' at 1155 line. So 'do_filter' is changed
  from 0x08 to 0x00 again. It make set the incorrect filter.

Change-Id: I418ce626193f7f1225a10f6c9bdd57e102fbdb53

pngwrite.c

index 5e68032..cbdf489 100644 (file)
@@ -1029,10 +1029,38 @@ png_set_filter(png_structrp png_ptr, int method, int filters)
          case 7: png_app_error(png_ptr, "Unknown row filter for method 0");
 #endif /* WRITE_FILTER */
             /* FALLTHROUGH */
+#ifdef __TIZEN__
+            /* 'switch ~ case' is dead code.
+             * If filters is #PNG_FILTER_VALUE_NONE, #PNG_FILTER_VALUE_SUB ...,
+             * filter flag will be assigned to 'png_ptr->do_filter'. But
+             * 'png_ptr->do_filter' is overwritten as 'filters' at below code.
+             * Issue code(#1155) is 'png_ptr->do_filter = (png_byte)filters;'.
+             * So the result of 'switch ~ case' has been lost at the line.
+             * To keep the value of 'switch ~ case', we fixed it to apply
+             * the result into 'filters'.
+             * It will be updated into 'png_ptr->do_filter' at #1155 line.
+             */
+         case PNG_FILTER_VALUE_NONE:
+            filters = PNG_FILTER_NONE; break;
+#else
          case PNG_FILTER_VALUE_NONE:
             png_ptr->do_filter = PNG_FILTER_NONE; break;
+#endif /* __TIZEN__ */
 
 #ifdef PNG_WRITE_FILTER_SUPPORTED
+#ifdef __TIZEN__
+         case PNG_FILTER_VALUE_SUB:
+            filters = PNG_FILTER_SUB; break;
+
+         case PNG_FILTER_VALUE_UP:
+            filters = PNG_FILTER_UP; break;
+
+         case PNG_FILTER_VALUE_AVG:
+            filters = PNG_FILTER_AVG; break;
+
+         case PNG_FILTER_VALUE_PAETH:
+            filters = PNG_FILTER_PAETH; break;
+#else
          case PNG_FILTER_VALUE_SUB:
             png_ptr->do_filter = PNG_FILTER_SUB; break;
 
@@ -1044,7 +1072,7 @@ png_set_filter(png_structrp png_ptr, int method, int filters)
 
          case PNG_FILTER_VALUE_PAETH:
             png_ptr->do_filter = PNG_FILTER_PAETH; break;
-
+#endif /* __TIZEN__ */
          default:
             png_ptr->do_filter = (png_byte)filters; break;
 #else