diff --git a/CHANGELOG.md b/CHANGELOG.md index 6fce4e96..7c8e7c8c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,12 @@ All changes to the Ox gem are documented here. Releases follow semantic versioning. +## [2.14.10] - 2022-03-10 + +### Fixed + +- Writing strings over 16K to a file with builder no longer causes a crash. + ## [2.14.9] - 2022-02-11 ### Fixed diff --git a/ext/ox/buf.h b/ext/ox/buf.h index c5a676b3..110798ba 100644 --- a/ext/ox/buf.h +++ b/ext/ox/buf.h @@ -86,8 +86,16 @@ buf_append_string(Buf buf, const char *s, size_t slen) { if (len != (size_t)write(buf->fd, buf->head, len)) { buf->err = true; + return; } buf->tail = buf->head; + if (sizeof(buf->base) <= slen) { + if (slen != (size_t)write(buf->fd, s, slen)) { + buf->err = true; + return; + } + return; + } } else { size_t len = buf->end - buf->head; size_t toff = buf->tail - buf->head; diff --git a/lib/ox/version.rb b/lib/ox/version.rb index 39e66ee8..22070b99 100644 --- a/lib/ox/version.rb +++ b/lib/ox/version.rb @@ -1,5 +1,5 @@ module Ox # Current version of the module. - VERSION = '2.14.9' + VERSION = '2.14.10' end