New issue
Advanced search Search tips

Issue 613623 link

Starred by 2 users

Issue metadata

Status: Fixed
Owner:
Closed: Jun 2016
Components:
EstimatedDays: ----
NextAction: ----
OS: Windows
Pri: 2
Type: Bug



Sign in to add a comment

Lots of pdfium bugs found by /analyze

Project Member Reported by brucedaw...@chromium.org, May 20 2016

Issue description

I found a batch of /analyze warnings in the pdfium\xfa code that all look legitimate. The first one may not be a bug but we should at least assert that the array is non-empty or, simpler yet, initialize dwID to zero. The others are all bugs, some of them of types that cropped up and were fixed in the non-XFA pdfium code.

The /analyzer builder was not working for a few weeks which is why these are coming in late.

pdfium\xfa\fwl\lightwidget\cfwl_theme.cpp(64) : warning C6001: Using uninitialized memory 'dwID'.

pdfium\xfa\fwl\theme\cfwl_checkboxtp.cpp(174) : warning C6313: Incorrect operator:  zero-valued flag cannot be tested with bitwise-and.  Use an equality test to check for zero-valued flags.

pdfium\xfa\fwl\theme\cfwl_formtp.cpp(86) : warning C6259: Labeled code is unreachable:  '(<expression> & 0x3)' in a switch-expr cannot evaluate to '0x80'.
pdfium\xfa\fwl\theme\cfwl_formtp.cpp(90) : warning C6259: Labeled code is unreachable:  '(<expression> & 0x3)' in a switch-expr cannot evaluate to '0x400'.
pdfium\xfa\fwl\theme\cfwl_formtp.cpp(94) : warning C6259: Labeled code is unreachable:  '(<expression> & 0x3)' in a switch-expr cannot evaluate to '0x8'.
pdfium\xfa\fwl\theme\cfwl_scrollbartp.cpp(55) : warning C6259: Labeled code is unreachable:  '(<expression> & 0x3)' in a switch-expr cannot evaluate to '0x80'.
pdfium\xfa\fwl\theme\cfwl_scrollbartp.cpp(59) : warning C6259: Labeled code is unreachable:  '(<expression> & 0x3)' in a switch-expr cannot evaluate to '0x400'.
pdfium\xfa\fwl\theme\cfwl_scrollbartp.cpp(63) : warning C6259: Labeled code is unreachable:  '(<expression> & 0x3)' in a switch-expr cannot evaluate to '0x8'.

pdfium\xfa\fxbarcode\datamatrix\bc_edifactencoder.cpp(135) : warning C6276: Cast between semantically different string types:  char * to wchar_t *.  Use of invalid string can lead to undefined behavior.
pdfium\xfa\fxbarcode\datamatrix\bc_errorcorrection.cpp(124) : warning C6276: Cast between semantically different string types:  char * to wchar_t *.  Use of invalid string can lead to undefined behavior.
pdfium\xfa\fxbarcode\datamatrix\bc_errorcorrection.cpp(132) : warning C6276: Cast between semantically different string types:  char * to wchar_t *.  Use of invalid string can lead to undefined behavior.
pdfium\xfa\fxbarcode\datamatrix\bc_errorcorrection.cpp(155) : warning C6276: Cast between semantically different string types:  char * to wchar_t *.  Use of invalid string can lead to undefined behavior.
pdfium\xfa\fxbarcode\datamatrix\bc_errorcorrection.cpp(182) : warning C6276: Cast between semantically different string types:  char * to wchar_t *.  Use of invalid string can lead to undefined behavior.
pdfium\xfa\fxbarcode\datamatrix\bc_highlevelencoder.cpp(81) : warning C6276: Cast between semantically different string types:  char * to wchar_t *.  Use of invalid string can lead to undefined behavior.
pdfium\xfa\fxbarcode\datamatrix\bc_symbolinfo.cpp(234) : warning C6276: Cast between semantically different string types:  char * to wchar_t *.  Use of invalid string can lead to undefined behavior.
pdfium\xfa\fxbarcode\datamatrix\bc_symbolinfo.cpp(238) : warning C6276: Cast between semantically different string types:  char * to wchar_t *.  Use of invalid string can lead to undefined behavior.
pdfium\xfa\fxbarcode\datamatrix\bc_symbolinfo.cpp(240) : warning C6276: Cast between semantically different string types:  char * to wchar_t *.  Use of invalid string can lead to undefined behavior.
pdfium\xfa\fxbarcode\datamatrix\bc_symbolinfo.cpp(243) : warning C6276: Cast between semantically different string types:  char * to wchar_t *.  Use of invalid string can lead to undefined behavior.
pdfium\xfa\fxbarcode\datamatrix\bc_symbolinfo.cpp(244) : warning C6276: Cast between semantically different string types:  char * to wchar_t *.  Use of invalid string can lead to undefined behavior.
pdfium\xfa\fxbarcode\datamatrix\bc_symbolinfo.cpp(246) : warning C6276: Cast between semantically different string types:  char * to wchar_t *.  Use of invalid string can lead to undefined behavior.
pdfium\xfa\fxbarcode\datamatrix\bc_symbolinfo.cpp(249) : warning C6276: Cast between semantically different string types:  char * to wchar_t *.  Use of invalid string can lead to undefined behavior.
pdfium\xfa\fxbarcode\datamatrix\bc_symbolinfo.cpp(250) : warning C6276: Cast between semantically different string types:  char * to wchar_t *.  Use of invalid string can lead to undefined behavior.
pdfium\xfa\fxbarcode\pdf417\bc_pdf417highlevelencoder.cpp(68) : warning C6276: Cast between semantically different string types:  char * to wchar_t *.  Use of invalid string can lead to undefined behavior.
 
Components: -Infra>Client>Pdfium Internals>Plugins>PDF
Labels: OS-Windows

Comment 2 by weili@chromium.org, May 20 2016

hi, Tom, I can take over this as I am fixing XFA code warnings anyway.

Comment 3 by tsepez@chromium.org, May 20 2016

Owner: weili@chromium.org
Ok, but a fix to the barcode stuff is in-flight.
Project Member

Comment 5 by bugdroid1@chromium.org, May 27 2016

The following revision refers to this bug:
  https://pdfium.googlesource.com/pdfium.git/+/bbff41927ecce2ff93668aa615307f548ca896eb

commit bbff41927ecce2ff93668aa615307f548ca896eb
Author: weili <weili@chromium.org>
Date: Fri May 27 21:48:10 2016

Fix two bugs found by /analyze tool

The first one is about bitwise AND on zero, the result would always
be zero. The second one is about using wrong bitmasks, the result would cause branches never get executed.

BUG= chromium:613623 ,  chromium:427616 

Review-Url: https://codereview.chromium.org/2016243003

[modify] https://crrev.com/bbff41927ecce2ff93668aa615307f548ca896eb/xfa/fwl/theme/cfwl_checkboxtp.cpp
[modify] https://crrev.com/bbff41927ecce2ff93668aa615307f548ca896eb/xfa/fwl/theme/cfwl_formtp.cpp

Project Member

Comment 7 by bugdroid1@chromium.org, Jun 2 2016

The following revision refers to this bug:
  https://pdfium.googlesource.com/pdfium.git/+/db444d2063df6c574882d9263e885c4fe1134133

commit db444d2063df6c574882d9263e885c4fe1134133
Author: weili <weili@chromium.org>
Date: Thu Jun 02 22:48:15 2016

Fix all the code which has duplicate variable declarations

When there are duplicate variable declarations, the inner names shadow the
outter ones. This is error prone and harder to read. Remove all the
instances found by /analyze.

BUG= chromium:613623 ,  chromium:427616 

Review-Url: https://codereview.chromium.org/2027273002

[modify] https://crrev.com/db444d2063df6c574882d9263e885c4fe1134133/core/fpdfapi/fpdf_edit/fpdf_edit_create.cpp
[modify] https://crrev.com/db444d2063df6c574882d9263e885c4fe1134133/core/fpdfapi/fpdf_font/cpdf_cidfont.cpp
[modify] https://crrev.com/db444d2063df6c574882d9263e885c4fe1134133/core/fpdfapi/fpdf_page/fpdf_page_parser.cpp
[modify] https://crrev.com/db444d2063df6c574882d9263e885c4fe1134133/core/fpdfapi/fpdf_parser/cpdf_security_handler.cpp
[modify] https://crrev.com/db444d2063df6c574882d9263e885c4fe1134133/core/fpdfapi/fpdf_parser/cpdf_syntax_parser.cpp
[modify] https://crrev.com/db444d2063df6c574882d9263e885c4fe1134133/core/fpdfapi/fpdf_parser/fpdf_parser_decode.cpp
[modify] https://crrev.com/db444d2063df6c574882d9263e885c4fe1134133/core/fpdfapi/fpdf_render/fpdf_render_loadimage.cpp
[modify] https://crrev.com/db444d2063df6c574882d9263e885c4fe1134133/core/fpdfdoc/doc_annot.cpp
[modify] https://crrev.com/db444d2063df6c574882d9263e885c4fe1134133/core/fpdftext/fpdf_text_int.cpp
[modify] https://crrev.com/db444d2063df6c574882d9263e885c4fe1134133/core/fxcodec/codec/fx_codec_fax.cpp
[modify] https://crrev.com/db444d2063df6c574882d9263e885c4fe1134133/core/fxge/dib/fx_dib_composite.cpp
[modify] https://crrev.com/db444d2063df6c574882d9263e885c4fe1134133/core/fxge/dib/fx_dib_convert.cpp
[modify] https://crrev.com/db444d2063df6c574882d9263e885c4fe1134133/core/fxge/dib/fx_dib_transform.cpp
[modify] https://crrev.com/db444d2063df6c574882d9263e885c4fe1134133/core/fxge/ge/fx_ge_device.cpp
[modify] https://crrev.com/db444d2063df6c574882d9263e885c4fe1134133/fpdfsdk/formfiller/cffl_iformfiller.cpp
[modify] https://crrev.com/db444d2063df6c574882d9263e885c4fe1134133/fpdfsdk/fpdf_flatten.cpp
[modify] https://crrev.com/db444d2063df6c574882d9263e885c4fe1134133/fpdfsdk/fpdf_transformpage.cpp
[modify] https://crrev.com/db444d2063df6c574882d9263e885c4fe1134133/fpdfsdk/javascript/Field.cpp
[modify] https://crrev.com/db444d2063df6c574882d9263e885c4fe1134133/fpdfsdk/jsapi/fxjs_v8_embeddertest.cpp
[modify] https://crrev.com/db444d2063df6c574882d9263e885c4fe1134133/fpdfsdk/pdfwindow/PWL_Edit.cpp
[modify] https://crrev.com/db444d2063df6c574882d9263e885c4fe1134133/xfa/fde/cfde_txtedtengine.cpp
[modify] https://crrev.com/db444d2063df6c574882d9263e885c4fe1134133/xfa/fde/cfx_wordbreak.cpp
[modify] https://crrev.com/db444d2063df6c574882d9263e885c4fe1134133/xfa/fde/tto/fde_textout.cpp
[modify] https://crrev.com/db444d2063df6c574882d9263e885c4fe1134133/xfa/fgas/font/fgas_gefont.cpp
[modify] https://crrev.com/db444d2063df6c574882d9263e885c4fe1134133/xfa/fgas/layout/fgas_rtfbreak.cpp
[modify] https://crrev.com/db444d2063df6c574882d9263e885c4fe1134133/xfa/fgas/layout/fgas_textbreak.cpp
[modify] https://crrev.com/db444d2063df6c574882d9263e885c4fe1134133/xfa/fwl/basewidget/fwl_comboboximp.cpp
[modify] https://crrev.com/db444d2063df6c574882d9263e885c4fe1134133/xfa/fwl/basewidget/fwl_datetimepickerimp.cpp
[modify] https://crrev.com/db444d2063df6c574882d9263e885c4fe1134133/xfa/fwl/basewidget/fwl_listboximp.cpp
[modify] https://crrev.com/db444d2063df6c574882d9263e885c4fe1134133/xfa/fxbarcode/BC_TwoDimWriter.cpp
[modify] https://crrev.com/db444d2063df6c574882d9263e885c4fe1134133/xfa/fxbarcode/common/reedsolomon/BC_ReedSolomonDecoder.cpp
[modify] https://crrev.com/db444d2063df6c574882d9263e885c4fe1134133/xfa/fxbarcode/datamatrix/BC_DataMatrixDataBlock.cpp
[modify] https://crrev.com/db444d2063df6c574882d9263e885c4fe1134133/xfa/fxbarcode/datamatrix/BC_DataMatrixDecoder.cpp
[modify] https://crrev.com/db444d2063df6c574882d9263e885c4fe1134133/xfa/fxbarcode/oned/BC_OneDimWriter.cpp
[modify] https://crrev.com/db444d2063df6c574882d9263e885c4fe1134133/xfa/fxfa/app/xfa_ffdocview.cpp
[modify] https://crrev.com/db444d2063df6c574882d9263e885c4fe1134133/xfa/fxfa/app/xfa_ffwidget.cpp
[modify] https://crrev.com/db444d2063df6c574882d9263e885c4fe1134133/xfa/fxfa/app/xfa_textlayout.cpp
[modify] https://crrev.com/db444d2063df6c574882d9263e885c4fe1134133/xfa/fxfa/fm2js/xfa_fm2jscontext.cpp
[modify] https://crrev.com/db444d2063df6c574882d9263e885c4fe1134133/xfa/fxfa/fm2js/xfa_fmparse.cpp
[modify] https://crrev.com/db444d2063df6c574882d9263e885c4fe1134133/xfa/fxfa/parser/xfa_document_datamerger_imp.cpp
[modify] https://crrev.com/db444d2063df6c574882d9263e885c4fe1134133/xfa/fxfa/parser/xfa_document_serialize.cpp
[modify] https://crrev.com/db444d2063df6c574882d9263e885c4fe1134133/xfa/fxfa/parser/xfa_layout_itemlayout.cpp
[modify] https://crrev.com/db444d2063df6c574882d9263e885c4fe1134133/xfa/fxfa/parser/xfa_layout_pagemgr_new.cpp
[modify] https://crrev.com/db444d2063df6c574882d9263e885c4fe1134133/xfa/fxfa/parser/xfa_object_imp.cpp
[modify] https://crrev.com/db444d2063df6c574882d9263e885c4fe1134133/xfa/fxfa/parser/xfa_script_imp.cpp

Project Member

Comment 8 by bugdroid1@chromium.org, Jun 3 2016

The following revision refers to this bug:
  https://pdfium.googlesource.com/pdfium.git/+/12367cb5e83e771cd67948c810fdd5f63d61af87

commit 12367cb5e83e771cd67948c810fdd5f63d61af87
Author: weili <weili@chromium.org>
Date: Fri Jun 03 18:22:16 2016

Fix some code which causes warnings when compiled by /analyze tool

The code may not cause error conditions, but can be improved. These
warnings include uninitialized variables, signed/unsigned mismatch,
redundant condition, and using bool in arithmetic operations.
Also remove a chunk of unused code.

BUG= chromium:613623 ,  chromium:427616 

Review-Url: https://codereview.chromium.org/2036203004

[modify] https://crrev.com/12367cb5e83e771cd67948c810fdd5f63d61af87/core/fpdfapi/fpdf_parser/fpdf_parser_decode_embeddertest.cpp
[modify] https://crrev.com/12367cb5e83e771cd67948c810fdd5f63d61af87/core/fpdfapi/fpdf_parser/fpdf_parser_decode_unittest.cpp
[modify] https://crrev.com/12367cb5e83e771cd67948c810fdd5f63d61af87/core/fxcodec/codec/fx_codec.cpp
[modify] https://crrev.com/12367cb5e83e771cd67948c810fdd5f63d61af87/core/fxcodec/codec/fx_codec_png.cpp
[modify] https://crrev.com/12367cb5e83e771cd67948c810fdd5f63d61af87/core/fxcodec/jbig2/JBig2_Context.cpp
[modify] https://crrev.com/12367cb5e83e771cd67948c810fdd5f63d61af87/fpdfsdk/fpdf_flatten.cpp
[modify] https://crrev.com/12367cb5e83e771cd67948c810fdd5f63d61af87/fpdfsdk/fsdk_baseannot.cpp
[modify] https://crrev.com/12367cb5e83e771cd67948c810fdd5f63d61af87/fpdfsdk/javascript/JS_Value.cpp

Project Member

Comment 9 by bugdroid1@chromium.org, Jun 3 2016

The following revision refers to this bug:
  https://pdfium.googlesource.com/pdfium.git/+/8d4e0d47f4cd0325be84ebf310fd8de989761939

commit 8d4e0d47f4cd0325be84ebf310fd8de989761939
Author: weili <weili@chromium.org>
Date: Fri Jun 03 21:06:36 2016

Fix more bugs found by /analyze tool

Three more bugs are discovered:
-- potientially used freed pointer;
-- potientially used uninitialized variable;
-- Used '&&' instead of bitwise operator '&'

BUG= chromium:613623 ,  chromium:427616 

Review-Url: https://codereview.chromium.org/2040503002

[modify] https://crrev.com/8d4e0d47f4cd0325be84ebf310fd8de989761939/core/fpdfapi/fpdf_parser/cpdf_stream_acc.cpp
[modify] https://crrev.com/8d4e0d47f4cd0325be84ebf310fd8de989761939/xfa/fwl/core/cfwl_widgetmgr.cpp
[modify] https://crrev.com/8d4e0d47f4cd0325be84ebf310fd8de989761939/xfa/fxfa/app/xfa_ffchoicelist.cpp

Status: Fixed (was: Assigned)

Sign in to add a comment