tracker r3038 - in trunk: . src/tracker-extract src/trackerd
- From: carlosg svn gnome org
- To: svn-commits-list gnome org
- Subject: tracker r3038 - in trunk: . src/tracker-extract src/trackerd
- Date: Mon, 9 Mar 2009 16:30:54 +0000 (UTC)
Author: carlosg
Date: Mon Mar 9 16:30:53 2009
New Revision: 3038
URL: http://svn.gnome.org/viewvc/tracker?rev=3038&view=rev
Log:
2009-03-09 Carlos Garnacho <carlos imendio com>
* src/tracker-extract/tracker-extract-ps.c (extract_ps_gz):
* src/trackerd/tracker-main.c (check_runtime_level): Do not leak file
descriptors.
Modified:
trunk/ChangeLog
trunk/src/tracker-extract/tracker-extract-ps.c
trunk/src/trackerd/tracker-main.c
Modified: trunk/src/tracker-extract/tracker-extract-ps.c
==============================================================================
--- trunk/src/tracker-extract/tracker-extract-ps.c (original)
+++ trunk/src/tracker-extract/tracker-extract-ps.c Mon Mar 9 16:30:53 2009
@@ -330,34 +330,48 @@
if (!ptat) {
g_unlink (gunzipped);
g_clear_error (&error);
+ close (fd);
return;
}
- if ((fz = fdopen (fdz, "r"))) {
- FILE *f;
+ fz = fdopen (fdz, "r");
- if ((f = fdopen (fd, "w"))) {
- unsigned char buf[8192];
- size_t w, b, accum;
- size_t max;
-
- /* 20 MiB should be enough! */
- accum = 0;
- max = 20u << 20;
-
- while ((b = fread (buf, 1, 8192, fz)) && accum <= max) {
- accum += b;
- w = 0;
-
- while (w < b) {
- w += fwrite (buf, 1, b, f);
- }
- }
+ if (!fz) {
+ g_unlink (gunzipped);
+ close (fdz);
+ close (fd);
+ return;
+ }
+
+ f = fdopen (fd, "w");
+
+ if (!f) {
+ g_unlink (gunzipped);
+ fclose (fz);
+ close (fd);
+ return;
+ }
+
+ if (f && fz) {
+ unsigned char buf[8192];
+ size_t w, b, accum;
+ size_t max;
+
+ /* 20 MiB should be enough! */
+ accum = 0;
+ max = 20u << 20;
+
+ while ((b = fread (buf, 1, 8192, fz)) && accum <= max) {
+ accum += b;
+ w = 0;
- fclose (f);
+ while (w < b) {
+ w += fwrite (buf, 1, b, f);
+ }
}
fclose (fz);
+ fclose (f);
}
extract_ps (gunzipped, metadata);
Modified: trunk/src/trackerd/tracker-main.c
==============================================================================
--- trunk/src/trackerd/tracker-main.c (original)
+++ trunk/src/trackerd/tracker-main.c Mon Mar 9 16:30:53 2009
@@ -301,6 +301,8 @@
#endif /* HAVE_HAL */
}
+ close (fd);
+
return runlevel;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]