[memprof: 45/76] detailwin.c: Fix possible crash when opening the maps file fails
- From: Holger Hans Peter Freyther <hfreyther src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [memprof: 45/76] detailwin.c: Fix possible crash when opening the maps file fails
- Date: Sun, 13 Jun 2010 03:42:01 +0000 (UTC)
commit c0efb775886428965bddf4e62332cc9f1b9bae42
Author: Holger Hans Peter Freyther <zecke selfish org>
Date: Mon Oct 26 02:05:16 2009 +0100
detailwin.c: Fix possible crash when opening the maps file fails
Check the return value of fopen and then stop looking at the
memory map. This is for the case that we get called after
the process has terminated or such.
* src/detailwin.c: Check the return value of fopen
src/detailwin.c | 6 ++++++
1 files changed, 6 insertions(+), 0 deletions(-)
---
diff --git a/src/detailwin.c b/src/detailwin.c
index 97be3c1..11dec9d 100644
--- a/src/detailwin.c
+++ b/src/detailwin.c
@@ -202,6 +202,12 @@ dw_draw_memmap(ProcessWindow *pwin)
snprintf(buffer, 1023, "/proc/%d/maps", pwin->process->pid);
in = fopen(buffer, "r");
+ if (!in)
+ {
+ g_warning("Failed to open: '%s'", buffer);
+ return;
+ }
+
while (fgets(buffer, 1023, in))
{
file[0] = 0;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]