Last Comment Bug 710970 - Possible bad null-check in mjit::Compiler::performCompilation()
: Possible bad null-check in mjit::Compiler::performCompilation()
Status: RESOLVED FIXED
[pvs-studio]
:
Product: Core
Classification: Components
Component: JavaScript Engine (show other bugs)
: unspecified
: All All
: -- normal (vote)
: mozilla12
Assigned To: David Mandelin [:dmandelin]
:
: Jason Orendorff [:jorendorff]
Mentors:
Depends on:
Blocks: 710966
  Show dependency treegraph
 
Reported: 2011-12-14 22:46 PST by Justin Dolske [:Dolske]
Modified: 2011-12-22 03:48 PST (History)
1 user (show)
See Also:
Crash Signature:
(edit)
QA Whiteboard:
Iteration: ---
Points: ---
Has Regression Range: ---
Has STR: ---


Attachments
Patch (934 bytes, patch)
2011-12-15 14:13 PST, David Mandelin [:dmandelin]
dvander: review+
Details | Diff | Splinter Review

Description Justin Dolske [:Dolske] 2011-12-14 22:46:06 PST
From http://www.viva64.com/en/a/0078/

Example 4. Checking a pointer for NULL only after it had been used

CompileStatus
mjit::Compiler::performCompilation(JITScript **jitp)
{
  ...
  JaegerSpew(JSpew_Scripts,
    "successfully compiled (code \"%p\") (size \"%u\")\n",
    (*jitp)->code.m_code.executableAddress(),
    unsigned((*jitp)->code.m_size));

  if (!*jitp)
      return Compile_Abort;
  ...
}

PVS-Studio diagnostic message: V595 The '* jitp' pointer was utilized before it was verified against nullptr. Check lines: 547, 549. compiler.cpp 547

By the way, using a pointer before checking it is a wide-spread error. This was one more example of this kind.
Comment 1 David Mandelin [:dmandelin] 2011-12-15 14:13:52 PST
Created attachment 582111 [details] [diff] [review]
Patch

False positive/nit: finishThisUp returns Okay only iff *jitp is non-null.
Comment 2 David Anderson [:dvander] 2011-12-16 13:43:43 PST
Comment on attachment 582111 [details] [diff] [review]
Patch

Gah hit wrong button.
Comment 3 David Mandelin [:dmandelin] 2011-12-21 17:03:14 PST
http://hg.mozilla.org/integration/mozilla-inbound/rev/092b0f19e65a
Comment 4 Ed Morley [:emorley] 2011-12-22 03:48:11 PST
https://hg.mozilla.org/mozilla-central/rev/092b0f19e65a

Note You need to log in before you can comment on or make changes to this bug.