Ticket #9886: 0014-Fix-use-of-memory-after-it-is-freed.patch

File 0014-Fix-use-of-memory-after-it-is-freed.patch, 1.5 KB (added by mt, 7 years ago)

Patch

  • src/kits/interface/PrintJob.cpp

    From 52449635b1c7a5dcf17cf8d05f1b37749dc2a77a Mon Sep 17 00:00:00 2001
    From: Murai Takashi <tmurai01@gmail.com>
    Date: Sat, 20 Jul 2013 20:58:17 +0900
    Subject: [PATCH] Fix use of memory after it is freed
    
    ---
     src/kits/interface/PrintJob.cpp |    8 ++++++--
     1 file changed, 6 insertions(+), 2 deletions(-)
    
    diff --git a/src/kits/interface/PrintJob.cpp b/src/kits/interface/PrintJob.cpp
    index 18a58da..90d023b 100644
    a b BPrintJob::BeginJob()  
    241241        return;
    242242
    243243    path.Append(printer);
    244     free(printer);
    245244
    246245    char mangledName[B_FILE_NAME_LENGTH];
    247246    _GetMangledName(mangledName, B_FILE_NAME_LENGTH);
    248247
    249248    path.Append(mangledName);
    250     if (path.InitCheck() != B_OK)
     249    if (path.InitCheck() != B_OK) {
     250        free(printer);
    251251        return;
     252    }
    252253
    253254    // TODO: fSpoolFileName should store the name only (not path which can be
    254255    // 1024 bytes long)
    BPrintJob::BeginJob()  
    256257    fSpoolFile = new BFile(fSpoolFileName, B_READ_WRITE | B_CREATE_FILE);
    257258
    258259    if (fSpoolFile->InitCheck() != B_OK) {
     260        free(printer);
    259261        CancelJob();
    260262        return;
    261263    }
    BPrintJob::BeginJob()  
    269271
    270272    if (fSpoolFile->Write(&fSpoolFileHeader, sizeof(print_file_header))
    271273            != sizeof(print_file_header)) {
     274        free(printer);
    272275        CancelJob();
    273276        return;
    274277    }
    BPrintJob::BeginJob()  
    277280    if (!fSetupMessage->HasString(PSRV_FIELD_CURRENT_PRINTER))
    278281        fSetupMessage->AddString(PSRV_FIELD_CURRENT_PRINTER, printer);
    279282
     283    free(printer);
    280284    _AddSetupSpec();
    281285    _NewPage();
    282286