Memleak in HPDirectJet printer transport
CID 605747
This commit is contained in:
@@ -52,11 +52,13 @@ HPJetDirectPort::HPJetDirectPort(BDirectory* printer, BMessage *msg)
|
|||||||
printf("fPort = %d\n", fPort);
|
printf("fPort = %d\n", fPort);
|
||||||
|
|
||||||
|
|
||||||
fEndpoint = new BNetEndpoint(SOCK_STREAM);
|
fEndpoint = new(std::nothrow) BNetEndpoint(SOCK_STREAM);
|
||||||
if ((fReady = fEndpoint->InitCheck()) != B_OK) {
|
if (fEndpoint == NULL || (fReady = fEndpoint->InitCheck()) != B_OK) {
|
||||||
BAlert *alert = new BAlert("", "Fail to create the NetEndpoint!", "OK");
|
BAlert *alert = new BAlert("", "Fail to create the NetEndpoint!", "OK");
|
||||||
alert->SetFlags(alert->Flags() | B_CLOSE_ON_ESCAPE);
|
alert->SetFlags(alert->Flags() | B_CLOSE_ON_ESCAPE);
|
||||||
alert->Go();
|
alert->Go();
|
||||||
|
delete fEndpoint;
|
||||||
|
fEndpoint = NULL;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -126,8 +126,8 @@ bool
|
|||||||
SetupView::CheckSetup()
|
SetupView::CheckSetup()
|
||||||
{
|
{
|
||||||
if (*fServerAddress->Text() && *fQueuePort->Text()) {
|
if (*fServerAddress->Text() && *fQueuePort->Text()) {
|
||||||
BNetEndpoint* ep = new BNetEndpoint(SOCK_STREAM);
|
BNetEndpoint* ep = new(std::nothrow) BNetEndpoint(SOCK_STREAM);
|
||||||
if (ep->InitCheck() == B_NO_ERROR) {
|
if (ep != NULL && ep->InitCheck() == B_NO_ERROR) {
|
||||||
uint16 port = atoi(fQueuePort->Text());
|
uint16 port = atoi(fQueuePort->Text());
|
||||||
|
|
||||||
if (! port)
|
if (! port)
|
||||||
@@ -135,10 +135,12 @@ SetupView::CheckSetup()
|
|||||||
|
|
||||||
if (ep->Connect(fServerAddress->Text(), port) != B_OK) {
|
if (ep->Connect(fServerAddress->Text(), port) != B_OK) {
|
||||||
BString text;
|
BString text;
|
||||||
text << "Failed to connect to " << fServerAddress->Text() << ":" << (int) port << "!";
|
text << "Failed to connect to " << fServerAddress->Text()
|
||||||
|
<< ":" << (int) port << "!";
|
||||||
BAlert* alert = new BAlert("", text.String(), "OK");
|
BAlert* alert = new BAlert("", text.String(), "OK");
|
||||||
alert->SetFlags(alert->Flags() | B_CLOSE_ON_ESCAPE);
|
alert->SetFlags(alert->Flags() | B_CLOSE_ON_ESCAPE);
|
||||||
alert->Go();
|
alert->Go();
|
||||||
|
delete ep;
|
||||||
return false;
|
return false;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -146,8 +148,10 @@ SetupView::CheckSetup()
|
|||||||
sprintf(str, "%s:%d", fServerAddress->Text(), port);
|
sprintf(str, "%s:%d", fServerAddress->Text(), port);
|
||||||
fPrinterDirectory->WriteAttr("transport_address", B_STRING_TYPE,
|
fPrinterDirectory->WriteAttr("transport_address", B_STRING_TYPE,
|
||||||
0, str, strlen(str) + 1);
|
0, str, strlen(str) + 1);
|
||||||
|
delete ep;
|
||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
|
delete ep;
|
||||||
};
|
};
|
||||||
|
|
||||||
BAlert* alert = new BAlert("", "Please input parameters.", "OK");
|
BAlert* alert = new BAlert("", "Please input parameters.", "OK");
|
||||||
|
|||||||
Reference in New Issue
Block a user