Skip to content

Commit

Permalink
More asserts and add sanitize to extconf
Browse files Browse the repository at this point in the history
  • Loading branch information
jhawthorn committed Apr 4, 2022
1 parent 538002b commit 09bc860
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
5 changes: 5 additions & 0 deletions ext/yajl/extconf.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,9 @@
$CFLAGS << ' -Wall -funroll-loops -Wno-declaration-after-statement'
$CFLAGS << ' -Werror-implicit-function-declaration -Wextra -O0 -ggdb3' if ENV['DEBUG']

if ENV['SANITIZE']
$CFLAGS << ' -fsanitize=address'
$LDFLAGS << ' -fsanitize=address'
end

create_makefile('yajl/yajl')
3 changes: 3 additions & 0 deletions ext/yajl/yajl_buf.c
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,8 @@ void yajl_buf_append(yajl_buf buf, const void * data, unsigned int len)

void yajl_buf_clear(yajl_buf buf)
{
assert(buf);
assert(!yajl_buf_err(buf));
buf->used = 0;
if (buf->data) buf->data[buf->used] = 0;
}
Expand All @@ -192,6 +194,7 @@ void
yajl_buf_truncate(yajl_buf buf, unsigned int len)
{
assert(buf);
assert(!yajl_buf_err(buf));
assert(len <= buf->used);
buf->used = len;
}

0 comments on commit 09bc860

Please sign in to comment.