[haiku-commits] haiku: hrev46267 - src/kits/interface

  • From: mattmadia@xxxxxxxxx
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Sun, 20 Oct 2013 20:46:44 +0200 (CEST)

hrev46267 adds 1 changeset to branch 'master'
old head: ab1ba83536e1d4b80c0ee35e86b5c9de8f49cb12
new head: ebea2b79f1e3bf14639af01c09dd7f48512910d2
overview: http://cgit.haiku-os.org/haiku/log/?qt=range&q=ebea2b7+%5Eab1ba83

----------------------------------------------------------------------------

ebea2b7: Fix use of memory after it is freed
  
  Signed-off-by: Matt Madia <mattmadia@xxxxxxxxx>

                                      [ Murai Takashi <tmurai01@xxxxxxxxx> ]

----------------------------------------------------------------------------

Revision:    hrev46267
Commit:      ebea2b79f1e3bf14639af01c09dd7f48512910d2
URL:         http://cgit.haiku-os.org/haiku/commit/?id=ebea2b7
Author:      Murai Takashi <tmurai01@xxxxxxxxx>
Date:        Sat Jul 20 11:58:17 2013 UTC
Committer:   Matt Madia <mattmadia@xxxxxxxxx>
Commit-Date: Sun Oct 20 18:41:20 2013 UTC

----------------------------------------------------------------------------

1 file changed, 6 insertions(+), 2 deletions(-)
src/kits/interface/PrintJob.cpp | 8 ++++++--

----------------------------------------------------------------------------

diff --git a/src/kits/interface/PrintJob.cpp b/src/kits/interface/PrintJob.cpp
index 18a58da..90d023b 100644
--- a/src/kits/interface/PrintJob.cpp
+++ b/src/kits/interface/PrintJob.cpp
@@ -241,14 +241,15 @@ BPrintJob::BeginJob()
                return;
 
        path.Append(printer);
-       free(printer);
 
        char mangledName[B_FILE_NAME_LENGTH];
        _GetMangledName(mangledName, B_FILE_NAME_LENGTH);
 
        path.Append(mangledName);
-       if (path.InitCheck() != B_OK)
+       if (path.InitCheck() != B_OK) {
+               free(printer);
                return;
+       }
 
        // TODO: fSpoolFileName should store the name only (not path which can 
be
        // 1024 bytes long)
@@ -256,6 +257,7 @@ BPrintJob::BeginJob()
        fSpoolFile = new BFile(fSpoolFileName, B_READ_WRITE | B_CREATE_FILE);
 
        if (fSpoolFile->InitCheck() != B_OK) {
+               free(printer);
                CancelJob();
                return;
        }
@@ -269,6 +271,7 @@ BPrintJob::BeginJob()
 
        if (fSpoolFile->Write(&fSpoolFileHeader, sizeof(print_file_header))
                        != sizeof(print_file_header)) {
+               free(printer);
                CancelJob();
                return;
        }
@@ -277,6 +280,7 @@ BPrintJob::BeginJob()
        if (!fSetupMessage->HasString(PSRV_FIELD_CURRENT_PRINTER))
                fSetupMessage->AddString(PSRV_FIELD_CURRENT_PRINTER, printer);
 
+       free(printer);
        _AddSetupSpec();
        _NewPage();
 


Other related posts:

  • » [haiku-commits] haiku: hrev46267 - src/kits/interface - mattmadia