]> git.ipfire.org Git - thirdparty/HylaFAX.git/commitdiff
1) Fix small possible memory leak on error path
authorAidan Van Dyk <aidan@ifax.com>
Tue, 22 Nov 2005 15:47:43 +0000 (15:47 +0000)
committerAidan Van Dyk <aidan@ifax.com>
Tue, 22 Nov 2005 15:47:43 +0000 (15:47 +0000)
2) new[] means we should be using delete[] operator

faxd/FaxRequest.c++

index 5fe027d962606be81ff8abdf78865d4359ff54b5..a5090a2ab3e73d57c6117602215c517c757eecaa 100644 (file)
@@ -206,12 +206,12 @@ FaxRequest::readQFile(bool& rejectJob)
     char stackbuf[2048];
     char* buf = stackbuf;
     char* bp = buf;
-    if (sb.st_size > (off_t)sizeof(buf)-1)     // extra byte for terminating \0
+    if (sb.st_size > (off_t)sizeof(stackbuf)-1)        // extra byte for terminating \0
        bp = buf = new char[sb.st_size+1];
     if (Sys::read(fd, bp, (u_int) sb.st_size) != sb.st_size) {
        error("Read error: %s", strerror(errno));
-       if (bp != buf)
-           delete bp;
+       if (buf != stackbuf)
+           delete [] buf;
        return (false);
     }
     /*
@@ -434,7 +434,7 @@ FaxRequest::readQFile(bool& rejectJob)
     if (desiredec > EC_ECLFULL)        desiredec = EC_ECLFULL;
     if (desireddf > DF_2DMMR)  desireddf = DF_2DMMR;
     if (buf != stackbuf)                       // dynamically allocated buffer
-       delete buf;
+       delete [] buf;
     return (true);
 }