qemacs-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemacs-commit] qemacs buffer.c


From: Charlie Gordon
Subject: [Qemacs-commit] qemacs buffer.c
Date: Tue, 22 Apr 2008 08:17:03 +0000

CVSROOT:        /cvsroot/qemacs
Module name:    qemacs
Changes by:     Charlie Gordon <chqrlie>        08/04/22 08:17:03

Modified files:
        .              : buffer.c 

Log message:
        some extra defensive code

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/qemacs/buffer.c?cvsroot=qemacs&r1=1.41&r2=1.42

Patches:
Index: buffer.c
===================================================================
RCS file: /cvsroot/qemacs/qemacs/buffer.c,v
retrieving revision 1.41
retrieving revision 1.42
diff -u -b -r1.41 -r1.42
--- buffer.c    20 Apr 2008 12:01:34 -0000      1.41
+++ buffer.c    22 Apr 2008 08:17:02 -0000      1.42
@@ -1362,10 +1362,11 @@
     size = 0;
     for (;;) {
         len = fread(buf, 1, IOBUF_SIZE, f);
-        if (len <= 0 && ferror(f))
+        if (len <= 0) {
+            if (ferror(f))
             return -1;
-        if (len == 0)
             break;
+        }
         eb_insert(b, offset, buf, len);
         offset += len;
         size += len;
@@ -1754,11 +1755,13 @@
 
     /* backup old file if present */
     if (strlen(filename) < MAX_FILENAME_SIZE - 1) {
-        snprintf(buf1, sizeof(buf1), "%s~", filename);
+        if (snprintf(buf1, sizeof(buf1), "%s~", filename) < ssizeof(buf1)) {
          // should check error code
         rename(filename, buf1);
     }
+    }
 
+    /* CG: should pass mode to buffer_save */
     ret = b->data_type->buffer_save(b, 0, b->total_size, filename);
     if (ret < 0)
         return ret;




reply via email to

[Prev in Thread] Current Thread [Next in Thread]