]> git.mdlowis.com Git - projs/tide.git/commitdiff
Fixed crash when saving an empty file
authorMichael D. Lowis <mike.lowis@gentex.com>
Fri, 3 Mar 2017 20:30:25 +0000 (15:30 -0500)
committerMichael D. Lowis <mike.lowis@gentex.com>
Fri, 3 Mar 2017 20:30:25 +0000 (15:30 -0500)
TODO.md
lib/buf.c

diff --git a/TODO.md b/TODO.md
index f88d475d5ae617544f90101340c4df00daa056c2..29419dfb3ba795f0494d4979dec30545e6244203 100644 (file)
--- a/TODO.md
+++ b/TODO.md
@@ -2,7 +2,6 @@
 
 Up Next:
 
-* save of an empty file crashes
 * implement 9term-like scrollbar
 * tab inserts dont coalesce like one would expect
 * check for file changes on save
@@ -35,4 +34,3 @@ The Future:
 * Win-like terminal emulator
 * File browser
 * Acme-like window manager
-
index 7f183ee1e14d9a27e81d01d2c8815d240b26aee9..22e12812247209f4c1e22f4fec65282a891cf706 100644 (file)
--- a/lib/buf.c
+++ b/lib/buf.c
@@ -233,6 +233,7 @@ unsigned buf_load(Buf* buf, char* path) {
 }
 
 void buf_save(Buf* buf) {
+    if (0 == buf_end(buf)) return;
     size_t wrlen = 0;
     if (!buf->path) return;
     FMap file = mmap_readwrite(buf->path, buf_end(buf) * UTF_MAX);