From: Michael D. Lowis Date: Fri, 3 Mar 2017 20:30:25 +0000 (-0500) Subject: Fixed crash when saving an empty file X-Git-Url: https://git.mdlowis.com/?a=commitdiff_plain;h=0558044ac79c1d612d58562e70628ca1d0fed0c6;p=projs%2Ftide.git Fixed crash when saving an empty file --- diff --git a/TODO.md b/TODO.md index f88d475..29419df 100644 --- 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 - diff --git a/lib/buf.c b/lib/buf.c index 7f183ee..22e1281 100644 --- 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);