Ignore:
Timestamp:
Jun 29, 2009, 7:19:18 PM (15 years ago)
Author:
Bruno Cornec
Message:

r3145@localhost: bruno | 2009-06-29 17:18:58 +0200

  • Remove 2 memory leaks and change the behavoir for function media_descriptor_string which now allocates the string it returns (which needs to be free by the caller)
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/2.2.9/mondo/src/common/libmondo-devices.c

    r2241 r2242  
    13591359    /*@ buffers ********************************************************* */
    13601360    char *tmp;
     1361    char *mds = NULL;
    13611362    char *request;
    13621363
     
    14101411        log_msg(3, "Currently, we hold %d but we want %d", res,
    14111412                cd_number_i_want);
    1412         sprintf(tmp, "Insisting on %s #%d",
    1413                 media_descriptor_string(bkpinfo->backup_media_type),
    1414                 cd_number_i_want);
    1415         sprintf(request, "Please insert %s #%d and press Enter.",
    1416                 media_descriptor_string(bkpinfo->backup_media_type),
    1417                 cd_number_i_want);
     1413        mds = media_descriptor_string(bkpinfo->backup_media_type);
     1414        sprintf(tmp, "Insisting on %s #%d", mds, cd_number_i_want);
     1415        sprintf(request, "Please insert %s #%d and press Enter.", mds, cd_number_i_want);
     1416        mr_free(mds);
    14181417        log_msg(3, tmp);
    14191418        while (what_number_cd_is_this() != cd_number_i_want) {
     
    14701469{
    14711470    char *tmp = NULL;
     1471    char *mds = NULL;
    14721472    char *sz_size;
    14731473    char *command;
     
    15341534                finish(1);
    15351535            }
    1536             sprintf(comment, "What speed is your %s (re)writer?",
    1537                     media_descriptor_string(bkpinfo->backup_media_type));
     1536            mds = media_descriptor_string(bkpinfo->backup_media_type);
     1537            sprintf(comment, "What speed is your %s (re)writer?", mds);
    15381538            if (bkpinfo->backup_media_type == dvd) {
    15391539                find_dvd_device(bkpinfo->media_device, FALSE);
     
    15571557
    15581558            sprintf(comment,
    1559                     "How much data (in Megabytes) will each %s store?",
    1560                     media_descriptor_string(bkpinfo->backup_media_type));
     1559                    "How much data (in Megabytes) will each %s store?", mds);
     1560            mr_free(mds);
    15611561            if (!popup_and_get_string("Size", comment, sz_size, 5)) {
    15621562                log_to_screen("User has chosen not to backup the PC");
     
    15731573        /* No break because we continue even for usb */
    15741574    case cdstream:
     1575        mds = media_descriptor_string(bkpinfo->backup_media_type);
     1576
    15751577        if ((bkpinfo->disaster_recovery) && (bkpinfo->backup_media_type != usb)) {
    15761578            strcpy(bkpinfo->media_device, "/dev/cdrom");
     
    15891591                        bkpinfo->media_device);
    15901592                sprintf(comment,
    1591                         "Please specify your %s drive's /dev entry",
    1592                         media_descriptor_string(bkpinfo->backup_media_type));
     1593                        "Please specify your %s drive's /dev entry", mds);
    15931594                if (!popup_and_get_string
    15941595                    ("Device?", comment, bkpinfo->media_device,
     
    15981599                }
    15991600            }
    1600             log_msg(2, "%s device found at %s",
    1601                     media_descriptor_string(bkpinfo->backup_media_type),
    1602                     bkpinfo->media_device);
     1601            log_msg(2, "%s device found at %s", mds, bkpinfo->media_device);
    16031602        } else {
    16041603            if ((find_cdrw_device(bkpinfo->media_device)) && (bkpinfo->backup_media_type != usb)) {
     
    16081607                if (bkpinfo->backup_media_type == usb) {
    16091608                    mr_asprintf(&tmp,
    1610                         "I think your %s media corresponds to %s. Is this correct?",
    1611                         media_descriptor_string(bkpinfo->backup_media_type),
     1609                        "I think your %s media corresponds to %s. Is this correct?", mds,
    16121610                        bkpinfo->media_device);
    16131611                } else {
    16141612                    mr_asprintf(&tmp,
    1615                         "I think I've found your %s burner at SCSI node %s. Is this correct? (Say no if you have an IDE burner and you are running a 2.6 kernel. You will then be prompted for further details.)",
    1616                         media_descriptor_string(bkpinfo->backup_media_type),
     1613                        "I think I've found your %s burner at SCSI node %s. Is this correct? (Say no if you have an IDE burner and you are running a 2.6 kernel. You will then be prompted for further details.)", mds,
    16171614                        bkpinfo->media_device);
    16181615                }
     
    16471644            }
    16481645        }
     1646        mr_free(mds);
     1647
    16491648        if (bkpinfo->backup_media_type == cdstream) {
    16501649            for (i = 0; i <= MAX_NOOF_MEDIA; i++) {
Note: See TracChangeset for help on using the changeset viewer.