Coverity PW.BRANCH_PAST_INITIALIZATION - CID 10729

Bug #957417 reported by Product Strategy Coverity Bug Uploader
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Application Menu Indicator
Fix Released
Medium
Charles Kerr
0.4
Fix Released
Medium
Charles Kerr

Bug Description

This bug is exported from the Coverity Integration Manager on Canonical's servers. For information on how this is done please see this website: https://wiki.ubuntu.com/CanonicalProductStrategy/Coverity
CID: 10729
Checker: PW.BRANCH_PAST_INITIALIZATION
Category: No category available
CWE definition: http://cwe.mitre.org/data/definitions/457.html
File: /tmp/buildd/indicator-appmenu-0.3.94/src/distance.c
Function: No function name available
Code snippet:
342
343 /* If we can't even find a set that works, let's just cut
344 our losses here */
345 if (num_needle_tokens > num_haystack_tokens) {
CID 10729 - PW.BRANCH_PAST_INITIALIZATION
transfer of control bypasses initialization of:
variable "distances" (declared at line 350)
variable "final_matches" (declared at line 373)
346 goto cleanup_tokens;
347 }
348
349 /* We need a place to store all the distances */
350 guint * distances = g_new0(guint, num_haystack_tokens * num_needle_tokens);
351

Related branches

Revision history for this message
Product Strategy Coverity Bug Uploader (coverity-uploader) wrote : indicator-appmenu-0.4: /tmp/buildd/indicator-appmenu-0.3.94/src/distance.c

Source file with Coverity annotations.

Changed in indicator-appmenu:
importance: Undecided → Medium
Revision history for this message
Charles Kerr (charlesk) wrote :

It's too bad that Coverity doesn't understand that "final_matches" and "distances" aren't referred to after the goto. IMO this is a false positive.

The "fix" is easy enough, removing the goto and changing the logic to "if (num_needle_tokens <= num_haystack_tokens) { /* everything before cleanup goes here */ }"

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.