Bug 1082346

Summary: magic_load() produces memory leaks
Product: [Fedora] Fedora Reporter: Tomas Mlcoch <tmlcoch>
Component: fileAssignee: Jan Kaluža <jkaluza>
Status: CLOSED ERRATA QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 20CC: jkaluza
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: file-5.19-1.fc20 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2014-07-05 14:53:13 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Attachments:
Description Flags
Reproducer none

Description Tomas Mlcoch 2014-03-30 13:41:52 UTC
Created attachment 880313 [details]
Reproducer

magic_load() produces memory leaks every time it's called.

See the attached reproducer.c

$ make clean && make && valgrind --leak-check=full ./reproducer 
rm -rf reproducer
gcc -Wall -Wextra -lmagic reproducer.c -o reproducer
==25855== Memcheck, a memory error detector
==25855== Copyright (C) 2002-2013, and GNU GPL'd, by Julian Seward et al.
==25855== Using Valgrind-3.9.0 and LibVEX; rerun with -h for copyright info
==25855== Command: ./reproducer
==25855== 
==25855== 
==25855== HEAP SUMMARY:
==25855==     in use at exit: 80 bytes in 4 blocks
==25855==   total heap usage: 24 allocs, 20 frees, 1,900 bytes allocated
==25855== 
==25855== 40 bytes in 1 blocks are definitely lost in loss record 2 of 3
==25855==    at 0x4C291D4: calloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==25855==    by 0x4E39BD8: file_apprentice (in /usr/lib64/libmagic.so.1.0.0)
==25855==    by 0x400929: main (in /home/tojaj/magic_file_reproducer/reproducer)
==25855== 
==25855== 40 bytes in 1 blocks are definitely lost in loss record 3 of 3
==25855==    at 0x4C291D4: calloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==25855==    by 0x4E3921A: ??? (in /usr/lib64/libmagic.so.1.0.0)
==25855==    by 0x4E39E4E: file_apprentice (in /usr/lib64/libmagic.so.1.0.0)
==25855==    by 0x400929: main (in /home/tojaj/magic_file_reproducer/reproducer)
==25855== 
==25855== LEAK SUMMARY:
==25855==    definitely lost: 80 bytes in 2 blocks
==25855==    indirectly lost: 0 bytes in 2 blocks
==25855==      possibly lost: 0 bytes in 0 blocks
==25855==    still reachable: 0 bytes in 0 blocks
==25855==         suppressed: 0 bytes in 0 blocks
==25855== 
==25855== For counts of detected and suppressed errors, rerun with: -v
==25855== ERROR SUMMARY: 2 errors from 2 contexts (suppressed: 2 from 2)

Comment 1 Jan Kaluža 2014-06-27 12:07:35 UTC
This is fixed in file-5.19 in rawhide.

Comment 2 Fedora Update System 2014-07-01 13:45:08 UTC
file-5.19-1.fc20 has been submitted as an update for Fedora 20.
https://admin.fedoraproject.org/updates/file-5.19-1.fc20

Comment 3 Fedora Update System 2014-07-01 23:32:48 UTC
Package file-5.19-1.fc20:
* should fix your issue,
* was pushed to the Fedora 20 testing repository,
* should be available at your local mirror within two days.
Update it with:
# su -c 'yum update --enablerepo=updates-testing file-5.19-1.fc20'
as soon as you are able to.
Please go to the following url:
https://admin.fedoraproject.org/updates/FEDORA-2014-7992/file-5.19-1.fc20
then log in and leave karma (feedback).

Comment 4 Fedora Update System 2014-07-05 14:53:13 UTC
file-5.19-1.fc20 has been pushed to the Fedora 20 stable repository.  If problems still persist, please make note of it in this bug report.