Menu

#86 Fix xvc_command_execute() implementation

SVN
closed-fixed
encoding (15)
5
2008-02-04
2008-02-02
No

A string is duplicated in a few cases of the function "xvc_command_execute". But the memory will never be released after its use. I am missing the call "free(myfile)".
Does the source code show a memory leak?

Discussion

  • Karl H. Beckers

    Karl H. Beckers - 2008-02-02

    Logged In: YES
    user_id=782084
    Originator: NO

    quite probably in several instances. Been trying to track them down with valgrind but that doesn't seem to work well on gtk apps.

     
  • Karl H. Beckers

    Karl H. Beckers - 2008-02-02
    • assigned_to: nobody --> charly4711
     
  • Karl H. Beckers

    Karl H. Beckers - 2008-02-02

    Logged In: YES
    user_id=782084
    Originator: NO

    fixed in svn

     
  • Karl H. Beckers

    Karl H. Beckers - 2008-02-02
    • status: open --> pending-fixed
     
  • Markus Elfring

    Markus Elfring - 2008-02-03
    • status: pending-fixed --> closed-fixed
     
  • Markus Elfring

    Markus Elfring - 2008-02-03

    Logged In: YES
    user_id=572001
    Originator: YES

    It must be considered that the string can only be deleted if it was dynamically allocated before (case 1/2). There is a dependency with the input parameter "file" if this pointer is really connected with a constant.

     
  • Markus Elfring

    Markus Elfring - 2008-02-03
    • status: closed-fixed --> open-later
     
  • Karl H. Beckers

    Karl H. Beckers - 2008-02-03
    • status: open-later --> pending-fixed
     
  • Karl H. Beckers

    Karl H. Beckers - 2008-02-03

    Logged In: YES
    user_id=782084
    Originator: NO

    done

     
  • Markus Elfring

    Markus Elfring - 2008-02-03

    Logged In: YES
    user_id=572001
    Originator: YES

    I hope that I am not nitpicking too much.
    http://xvidcap.svn.sourceforge.net/viewvc/xvidcap/trunk/src/app_data.c?r1=298&r2=300

    Your approach seems still to be incomplete because of the "case 2" implementation. I recommend to store into a boolean variable if the free() call will be required.
    I feel a bit uncomfortable with such handling for special cases.

     
  • Markus Elfring

    Markus Elfring - 2008-02-03
    • status: pending-fixed --> open-later
     
  • Karl H. Beckers

    Karl H. Beckers - 2008-02-03
    • status: open-later --> pending-fixed
     
  • Karl H. Beckers

    Karl H. Beckers - 2008-02-03

    Logged In: YES
    user_id=782084
    Originator: NO

    Hmm, another oversight ... grrr
    anyway, since the issue here is that I either construct a filename or take the one passed, I should be able to compare the two pointers, hence:
    $ svn diff -r 301:300 src/app_data.c
    Index: src/app_data.c
    ===================================================================
    --- src/app_data.c (Revision 301)
    +++ src/app_data.c (Revision 300)
    @@ -2703,9 +2703,12 @@
    // sf-edit: flag 2
    // gimp "${XVFILE}" &

    - // in case we constructed a filename pattern, we need to free it again
    - if (myfile != file)
    - free ((void *) myfile);
    + switch (flag) {
    + case 1:
    + case 2:
    + free ((void *) myfile);
    + break;
    + }

     
  • Markus Elfring

    Markus Elfring - 2008-02-04

    Logged In: YES
    user_id=572001
    Originator: YES

    Thanks.

     
  • Markus Elfring

    Markus Elfring - 2008-02-04
    • status: pending-fixed --> closed-fixed
     

Log in to post a comment.