[dconf] dconf-update: don't leak fd on insuccessful write
- From: Ryan Lortie <ryanl src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [dconf] dconf-update: don't leak fd on insuccessful write
- Date: Mon, 19 Jul 2010 01:56:33 +0000 (UTC)
commit 4c375030eb6254b757b6fa1bba6dbd0c5d69774f
Author: Ryan Lortie <desrt desrt ca>
Date: Sun Jul 18 21:55:43 2010 -0400
dconf-update: don't leak fd on insuccessful write
bin/dconf-update.vala | 13 +++++++++----
1 files changed, 9 insertions(+), 4 deletions(-)
---
diff --git a/bin/dconf-update.vala b/bin/dconf-update.vala
index 9a81140..9ea6057 100644
--- a/bin/dconf-update.vala
+++ b/bin/dconf-update.vala
@@ -98,11 +98,16 @@ void maybe_update_from_directory (string dirname) throws GLib.Error {
throw new FileError.FAILED ("Can not open '%s' for replacement: %s", filename, strerror (saved_error));
}
- table.write_contents (filename);
+ try {
+ table.write_contents (filename);
- if (fd >= 0) {
- Posix.write (fd, "\0\0\0\0\0\0\0\0", 8);
- Posix.close (fd);
+ if (fd >= 0) {
+ Posix.write (fd, "\0\0\0\0\0\0\0\0", 8);
+ }
+ } finally {
+ if (fd >= 0) {
+ Posix.close (fd);
+ }
}
try {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]