Prevent ressource leak in time preferences (ntp update) CID 702055.
This commit is contained in:
@@ -153,6 +153,7 @@ ntp_update_time(const char* hostname, const char** errorString,
|
|||||||
0, (struct sockaddr *)&address, sizeof(address)) < 0) {
|
0, (struct sockaddr *)&address, sizeof(address)) < 0) {
|
||||||
*errorString = B_TRANSLATE("Sending request failed");
|
*errorString = B_TRANSLATE("Sending request failed");
|
||||||
*errorCode = errno;
|
*errorCode = errno;
|
||||||
|
close(connection);
|
||||||
return B_ERROR;
|
return B_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -168,6 +169,7 @@ ntp_update_time(const char* hostname, const char** errorString,
|
|||||||
if (select(connection + 1, &waitForReceived, NULL, NULL, &timeout) <= 0) {
|
if (select(connection + 1, &waitForReceived, NULL, NULL, &timeout) <= 0) {
|
||||||
*errorString = B_TRANSLATE("Waiting for answer failed");
|
*errorString = B_TRANSLATE("Waiting for answer failed");
|
||||||
*errorCode = errno;
|
*errorCode = errno;
|
||||||
|
close(connection);
|
||||||
return B_ERROR;
|
return B_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user