Status

()

Firefox for Android
General
RESOLVED DUPLICATE of bug 1142667
6 months ago
6 months ago

People

(Reporter: snorp, Unassigned)

Tracking

Firefox Tracking Flags

(Not tracked)

Details

Coverity static analysis found the following leaks in elfhack.cpp. It appears they are all related to early returns leaking the 'relhack' instance that is newed up near the beginning of do_relocation_section()


** CID 158597:    (RESOURCE_LEAK)
/build/unix/elfhack/elfhack.cpp: 615 in do_relocation_section<Elf_Rela>(Elf *, unsigned int, unsigned int, bool, bool)()
/build/unix/elfhack/elfhack.cpp: 615 in do_relocation_section<Elf_Rel>(Elf *, unsigned int, unsigned int, bool, bool)()
/build/unix/elfhack/elfhack.cpp: 746 in do_relocation_section<Elf_Rela>(Elf *, unsigned int, unsigned int, bool, bool)()
/build/unix/elfhack/elfhack.cpp: 746 in do_relocation_section<Elf_Rela>(Elf *, unsigned int, unsigned int, bool, bool)()
/build/unix/elfhack/elfhack.cpp: 746 in do_relocation_section<Elf_Rel>(Elf *, unsigned int, unsigned int, bool, bool)()
/build/unix/elfhack/elfhack.cpp: 746 in do_relocation_section<Elf_Rel>(Elf *, unsigned int, unsigned int, bool, bool)()


________________________________________________________________________________________________________
*** CID 158597:    (RESOURCE_LEAK)
/build/unix/elfhack/elfhack.cpp: 615 in do_relocation_section<Elf_Rela>(Elf *, unsigned int, unsigned int, bool, bool)()
609                 }
610             }
611             // Keep track of the relocation associated with the first init_array entry.
612             if (init_array && i->r_offset == init_array->getAddr()) {
613                 if (init_array_reloc) {
614                     fprintf(stderr, "Found multiple relocations for the first init_array entry. Skipping\n");
>>>     CID 158597:    (RESOURCE_LEAK)
>>>     Variable "relhack" going out of scope leaks the storage it points to.
615                     return -1;
616                 }
617                 new_rels.push_back(*i);
618                 init_array_reloc = new_rels.size();
619             } else if (!(loc.getSection()->getFlags() & SHF_WRITE) || (ELF32_R_TYPE(i->r_info) != rel_type)) {
620                 // Don't pack relocations happening in non writable sections.
/build/unix/elfhack/elfhack.cpp: 615 in do_relocation_section<Elf_Rel>(Elf *, unsigned int, unsigned int, bool, bool)()
609                 }
610             }
611             // Keep track of the relocation associated with the first init_array entry.
612             if (init_array && i->r_offset == init_array->getAddr()) {
613                 if (init_array_reloc) {
614                     fprintf(stderr, "Found multiple relocations for the first init_array entry. Skipping\n");
>>>     CID 158597:    (RESOURCE_LEAK)
>>>     Variable "relhack" going out of scope leaks the storage it points to.
615                     return -1;
616                 }
617                 new_rels.push_back(*i);
618                 init_array_reloc = new_rels.size();
619             } else if (!(loc.getSection()->getFlags() & SHF_WRITE) || (ELF32_R_TYPE(i->r_info) != rel_type)) {
620                 // Don't pack relocations happening in non writable sections.
/build/unix/elfhack/elfhack.cpp: 746 in do_relocation_section<Elf_Rela>(Elf *, unsigned int, unsigned int, bool, bool)()
740                     break;
741                 }
742             }
743
744             if (mprotect_cb == 0) {
745                 fprintf(stderr, "Couldn't find .bss. Skipping\n");
>>>     CID 158597:    (RESOURCE_LEAK)
>>>     Variable "relhack" going out of scope leaks the storage it points to.
746                 return -1;
747             }
748         }
749
750         section->rels.assign(new_rels.begin(), new_rels.end());
751         section->shrink(new_rels.size() * section->getEntSize());
/build/unix/elfhack/elfhack.cpp: 746 in do_relocation_section<Elf_Rela>(Elf *, unsigned int, unsigned int, bool, bool)()
740                     break;
741                 }
742             }
743
744             if (mprotect_cb == 0) {
745                 fprintf(stderr, "Couldn't find .bss. Skipping\n");
>>>     CID 158597:    (RESOURCE_LEAK)
>>>     Variable "relhack" going out of scope leaks the storage it points to.
746                 return -1;
747             }
748         }
749
750         section->rels.assign(new_rels.begin(), new_rels.end());
751         section->shrink(new_rels.size() * section->getEntSize());
/build/unix/elfhack/elfhack.cpp: 746 in do_relocation_section<Elf_Rel>(Elf *, unsigned int, unsigned int, bool, bool)()
740                     break;
741                 }
742             }
743
744             if (mprotect_cb == 0) {
745                 fprintf(stderr, "Couldn't find .bss. Skipping\n");
>>>     CID 158597:    (RESOURCE_LEAK)
>>>     Variable "relhack" going out of scope leaks the storage it points to.
746                 return -1;
747             }
748         }
749
750         section->rels.assign(new_rels.begin(), new_rels.end());
751         section->shrink(new_rels.size() * section->getEntSize());
/build/unix/elfhack/elfhack.cpp: 746 in do_relocation_section<Elf_Rel>(Elf *, unsigned int, unsigned int, bool, bool)()
740                     break;
741                 }
742             }
743
744             if (mprotect_cb == 0) {
745                 fprintf(stderr, "Couldn't find .bss. Skipping\n");
>>>     CID 158597:    (RESOURCE_LEAK)
>>>     Variable "relhack" going out of scope leaks the storage it points to.
746                 return -1;
747             }
748         }
749
750         section->rels.assign(new_rels.begin(), new_rels.end());
751         section->shrink(new_rels.size() * section->getEntSize());

Updated

6 months ago
Status: NEW → RESOLVED
Last Resolved: 6 months ago
Resolution: --- → DUPLICATE
Duplicate of bug: 1142667
You need to log in before you can comment on or make changes to this bug.