From 163cd4bf53064ff57a1feadc14f04d7c09fc8efc Mon Sep 17 00:00:00 2001 From: Philippe Saint-Pierre Date: Sun, 10 Jun 2012 16:57:45 -0400 Subject: [PATCH] Prevent ressource leak in time preferences (ntp update) CID 702055. --- src/preferences/time/ntp.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/preferences/time/ntp.cpp b/src/preferences/time/ntp.cpp index 7ee56be4a1..167ef2ca4b 100644 --- a/src/preferences/time/ntp.cpp +++ b/src/preferences/time/ntp.cpp @@ -153,6 +153,7 @@ ntp_update_time(const char* hostname, const char** errorString, 0, (struct sockaddr *)&address, sizeof(address)) < 0) { *errorString = B_TRANSLATE("Sending request failed"); *errorCode = errno; + close(connection); 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) { *errorString = B_TRANSLATE("Waiting for answer failed"); *errorCode = errno; + close(connection); return B_ERROR; }