Project

General

Profile

Bug #1670

Uninitialized variable in WSuggestionPopup

Added by Bruce Toll over 7 years ago. Updated over 7 years ago.

Status:
Closed
Priority:
Low
Assignee:
-
Target version:
Start date:
02/04/2013
Due date:
% Done:

0%

Estimated time:

Description

Valgrind detected an uninitialized variable in WSuggestionPopup with our application using Wt 3.2.3. It did not cause any noticeable problems. I believe the issue is that defaultValue_ is not initialized by the constructor defined in WSuggestionPopup.C, starting at line 54.

Here's the relevant output from valgrind:

Conditional jump or move depends on uninitialised value(s)
   at: boost::make_unsigned<int>::type boost::detail::lcast_to_unsigned<int>(int) (lexical_cast.hpp:533)
   by: bool boost::detail::lexical_stream_limited_src<char, std::char_traits<char>, false>::shl_signed<int>(int) (lexical_cast.hpp:1269)
   by: boost::detail::lexical_stream_limited_src<char, std::char_traits<char>, false>::operator<<(int) (lexical_cast.hpp:1408)
   by: boost::detail::lexical_cast_do_cast<std::string, int>::lexical_cast_impl(int const&) (lexical_cast.hpp:1921)
   by: std::string boost::lexical_cast<std::string, int>(int const&) (lexical_cast.hpp:2088)
   by: Wt::WSuggestionPopup::defineJavaScript() (WSuggestionPopup.C:143)
   by: Wt::WSuggestionPopup::render(Wt::WFlags<Wt::RenderFlag>) (WSuggestionPopup.C:149)
   by: Wt::WWidget::createSDomElement(Wt::WApplication*) (WWidget.C:326)
   by: Wt::WContainerWidget::createDomChildren(Wt::DomElement&, Wt::WApplication*) (WContainerWidget.C:724)
   by: Wt::WContainerWidget::createDomElement(Wt::WApplication*, bool) (WContainerWidget.C:658)
   by: Wt::WContainerWidget::createDomElement(Wt::WApplication*) (WContainerWidget.C:646)
   by: Wt::WWebWidget::createActualElement(Wt::WApplication*) (WWebWidget.C:1952)
   by: ...

The following patch was tested and prevents the warning from valgrind. However, I'm not familiar enough with the code to say it is a good/correct solution.

diff --git a/src/Wt/WSuggestionPopup.C b/src/Wt/WSuggestionPopup.C
--- a/src/Wt/WSuggestionPopup.C
+++ b/src/Wt/WSuggestionPopup.C
@@ -59,6 +59,7 @@ WSuggestionPopup::WSuggestionPopup(const Options& options,
     modelColumn_(0),
     filterLength_(0),
     filtering_(false),
+    defaultValue_(-1),
     matcherJS_(generateMatcherJS(options)),
     replacerJS_(generateReplacerJS(options)),
     filterModel_(this),

I believe the issue may still exist on the development branch, but I haven't tested to be sure.

#1

Updated by Koen Deforche over 7 years ago

  • Status changed from New to Resolved

Hey,

Thanks for spotting this, indeed it still existed in git.

Regards,

koen

#2

Updated by Koen Deforche over 7 years ago

  • Target version changed from 3.2.3 to 3.3.0
#3

Updated by Koen Deforche over 7 years ago

  • Status changed from Resolved to Closed

Also available in: Atom PDF