Note: This is a beta release of Red Hat Bugzilla 5.0. The data contained within is a snapshot of the live data so any changes you make will not be reflected in the production Bugzilla. Also email is disabled so feel free to test any aspect of the site that you want. File any problems you find or give feedback here.
Bug 1689801 - possible memory leak in sedispatch
Summary: possible memory leak in sedispatch
Status: NEW
Alias: None
Product: Fedora
Classification: Fedora
Component: setroubleshoot
Version: 29
Hardware: All
OS: Linux
Target Milestone: ---
Assignee: Daniel Walsh
QA Contact: Fedora Extras Quality Assurance
Depends On:
TreeView+ depends on / blocked
Reported: 2019-03-18 07:40 UTC by shoulianyu
Modified: 2019-03-18 07:40 UTC (History)
4 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Last Closed:

Attachments (Terms of Use)

Description shoulianyu 2019-03-18 07:40:16 UTC
Description of problem:
in src/sedbus.c, sedbus_send_avc doesn't free msg created by dbus_message_new_method_call in case of error:
        msg = dbus_message_new_method_call(BUSNAME,
                                           "avc"); // method name
        if (NULL == msg) {
                fprintf(stderr, "Can't communicate with setroubleshootd\n");
                return -1;
        // append arguments
        dbus_message_iter_init_append(msg, &args);
        if (!dbus_message_iter_append_basic(&args, DBUS_TYPE_STRING, &avc)) {
                fprintf(stderr, "Out Of Memory!\n");
                return -1; //****** possible msg leak ***********

        // send message and get a handle for a reply
        if ( ! dbus_connection_send_with_reply (conn, msg, &pending, -1)) {
                // -1 is default timeout
                fprintf(stderr, "Out Of Memory!\n");
                return -1; //****** possible msg leak ***********
        if (NULL == pending) {
                fprintf(stderr, "Pending Call Null\n");
                return -1; //****** possible msg leak ***********

        // free message

        // block until we receive a reply

        // get the reply message
        msg = dbus_pending_call_steal_reply(pending);
        if (NULL == msg) {
                fprintf(stderr, "Reply Null\n");
                exit(1); //********* why exit the entire sedispatch process? "return -1" intended? **********

Version-Release number of selected component (if applicable):

How reproducible:
Code review found  the aforementioned code  is **very** similar to the following tutorial code segment(Calling a method setion):

one major difference is "exit(1)" is replaced by "return -1", this change could result in possible memory leaks. 

One more thing: the 'Reply Null' case 'exit(1)' is not replaced by 'return -1', which looks weird.

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