[PATCH 1/2] NULL pointer check to cReadline.read in tools.c

Mika Laitio lamikr at pilppa.org
Sun Apr 3 12:06:55 CEST 2011


Signed-off-by: Mika Laitio <lamikr at pilppa.org>
---
 tools.c |   22 ++++++++++++----------
 1 files changed, 12 insertions(+), 10 deletions(-)

diff --git a/tools.c b/tools.c
index d03595e..c09a9b0 100644
--- a/tools.c
+++ b/tools.c
@@ -1191,18 +1191,20 @@ cReadLine::~cReadLine()
 
 char *cReadLine::Read(FILE *f)
 {
-  int n = getline(&buffer, &size, f);
-  if (n > 0) {
-     n--;
-     if (buffer[n] == '\n') {
-        buffer[n] = 0;
-        if (n > 0) {
-           n--;
-           if (buffer[n] == '\r')
-              buffer[n] = 0;
+  if (f != NULL) {
+     int n = getline(&buffer, &size, f);
+     if (n > 0) {
+        n--;
+        if (buffer[n] == '\n') {
+           buffer[n] = 0;
+           if (n > 0) {
+              n--;
+              if (buffer[n] == '\r')
+                 buffer[n] = 0;
+              }
            }
+        return buffer;
         }
-     return buffer;
      }
   return NULL;
 }
-- 
1.7.3.4


--------------080200080109040002030409
Content-Type: text/plain;
 name="0002-NULL-pointer-check-for-file-at-cRecordingInfo-Read-F.patch"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
 filename*0="0002-NULL-pointer-check-for-file-at-cRecordingInfo-Read-F.pa";
 filename*1="tch"



More information about the vdr mailing list