do error checking instead of segfaulting
authorThomas Vander Stichele <thomas@apestaart.org>
Fri, 16 Apr 2004 10:17:55 +0000 (10:17 +0000)
committerThomas Vander Stichele <thomas@apestaart.org>
Fri, 16 Apr 2004 10:17:55 +0000 (10:17 +0000)
Original commit message from CVS:
do error checking instead of segfaulting

ChangeLog
tests/old/testsuite/refcounting/mem.c
testsuite/refcounting/mem.c

index 44186f5..696410e 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2004-04-16  Thomas Vander Stichele  <thomas at apestaart dot org>
+
+       * testsuite/refcounting/mem.c: (vmsize):
+          do error checking
+
 2004-04-16  Johan Dahlin  <johan@gnome.org>
 
        * docs/gst/gstreamer-sections.txt: Add gst_pad_call_chain_function
index 433918a..5911dc6 100644 (file)
@@ -13,7 +13,13 @@ vmsize ()
   pid = getpid ();
   snprintf (filename, 17, "/proc/%d/stat", pid);
   fd = open (filename, O_RDONLY);
+  if (fd == -1) {
+    fprintf (stderr, "warning: could not open %s\n", filename);
+    return -1;
+  }
   size = read (fd, buf, 240);
+  if (size == -1)
+    return -1;
   ptr = buf;
   for (i = 0; i < 22; i++)
     ptr = (char *) strchr (ptr, ' ') + 1;
index 433918a..5911dc6 100644 (file)
@@ -13,7 +13,13 @@ vmsize ()
   pid = getpid ();
   snprintf (filename, 17, "/proc/%d/stat", pid);
   fd = open (filename, O_RDONLY);
+  if (fd == -1) {
+    fprintf (stderr, "warning: could not open %s\n", filename);
+    return -1;
+  }
   size = read (fd, buf, 240);
+  if (size == -1)
+    return -1;
   ptr = buf;
   for (i = 0; i < 22; i++)
     ptr = (char *) strchr (ptr, ' ') + 1;