From fc0d93fc66c5fe1b95b541a39796aef85720caf1 Mon Sep 17 00:00:00 2001 From: Nigel Tao Date: Sun, 7 Jul 2019 17:59:11 +1000 Subject: [PATCH] Reject nullptr-valued io_buffer* args MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit name old speed new speed delta wuffs_gif_decode_1k_bw/clang5 417MB/s ± 0% 417MB/s ± 0% ~ (p=0.841 n=5+5) wuffs_gif_decode_1k_color_full_init/clang5 136MB/s ± 1% 135MB/s ± 0% -1.07% (p=0.008 n=5+5) wuffs_gif_decode_1k_color_part_init/clang5 180MB/s ± 0% 177MB/s ± 0% -1.49% (p=0.016 n=4+5) wuffs_gif_decode_10k_bgra/clang5 733MB/s ± 0% 733MB/s ± 0% ~ (p=1.000 n=5+5) wuffs_gif_decode_10k_indexed/clang5 197MB/s ± 0% 196MB/s ± 0% -0.43% (p=0.032 n=5+5) wuffs_gif_decode_20k/clang5 245MB/s ± 0% 249MB/s ± 0% +1.59% (p=0.008 n=5+5) wuffs_gif_decode_100k_artificial/clang5 548MB/s ± 0% 553MB/s ± 0% +0.97% (p=0.008 n=5+5) wuffs_gif_decode_100k_realistic/clang5 223MB/s ± 0% 226MB/s ± 0% +1.48% (p=0.008 n=5+5) wuffs_gif_decode_1000k_full_init/clang5 226MB/s ± 0% 229MB/s ± 1% +1.66% (p=0.008 n=5+5) wuffs_gif_decode_1000k_part_init/clang5 226MB/s ± 0% 229MB/s ± 0% +1.51% (p=0.008 n=5+5) wuffs_gif_decode_anim_screencap/clang5 1.10GB/s ± 0% 1.11GB/s ± 0% +0.91% (p=0.008 n=5+5) wuffs_gif_decode_1k_bw/gcc7 465MB/s ± 2% 480MB/s ± 2% +3.22% (p=0.008 n=5+5) wuffs_gif_decode_1k_color_full_init/gcc7 142MB/s ± 1% 143MB/s ± 1% +1.18% (p=0.008 n=5+5) wuffs_gif_decode_1k_color_part_init/gcc7 186MB/s ± 0% 189MB/s ± 0% +1.64% (p=0.008 n=5+5) wuffs_gif_decode_10k_bgra/gcc7 634MB/s ± 0% 636MB/s ± 0% +0.45% (p=0.016 n=5+5) wuffs_gif_decode_10k_indexed/gcc7 198MB/s ± 0% 200MB/s ± 0% +0.86% (p=0.008 n=5+5) wuffs_gif_decode_20k/gcc7 243MB/s ± 0% 245MB/s ± 0% +1.11% (p=0.016 n=4+5) wuffs_gif_decode_100k_artificial/gcc7 514MB/s ± 1% 516MB/s ± 1% ~ (p=0.310 n=5+5) wuffs_gif_decode_100k_realistic/gcc7 210MB/s ± 0% 214MB/s ± 0% +1.67% (p=0.008 n=5+5) wuffs_gif_decode_1000k_full_init/gcc7 215MB/s ± 0% 218MB/s ± 0% +1.53% (p=0.008 n=5+5) wuffs_gif_decode_1000k_part_init/gcc7 215MB/s ± 0% 218MB/s ± 0% +1.54% (p=0.008 n=5+5) wuffs_gif_decode_anim_screencap/gcc7 1.07GB/s ± 1% 1.08GB/s ± 1% ~ (p=0.095 n=5+5) wuffs_deflate_decode_1k_full_init/clang5 156MB/s ± 0% 140MB/s ± 0% -10.04% (p=0.008 n=5+5) wuffs_deflate_decode_1k_part_init/clang5 192MB/s ± 0% 170MB/s ± 0% -11.83% (p=0.008 n=5+5) wuffs_deflate_decode_10k_full_init/clang5 227MB/s ± 1% 242MB/s ± 0% +6.61% (p=0.008 n=5+5) wuffs_deflate_decode_10k_part_init/clang5 234MB/s ± 0% 249MB/s ± 0% +6.79% (p=0.008 n=5+5) wuffs_deflate_decode_100k_just_one_read/clang5 282MB/s ± 0% 280MB/s ± 0% -0.64% (p=0.008 n=5+5) wuffs_deflate_decode_100k_many_big_reads/clang5 238MB/s ± 0% 229MB/s ± 0% -3.71% (p=0.008 n=5+5) wuffs_deflate_decode_1k_full_init/gcc7 157MB/s ± 0% 158MB/s ± 0% +0.40% (p=0.032 n=5+5) wuffs_deflate_decode_1k_part_init/gcc7 194MB/s ± 0% 194MB/s ± 0% ~ (p=0.151 n=5+5) wuffs_deflate_decode_10k_full_init/gcc7 267MB/s ± 0% 266MB/s ± 0% ~ (p=0.222 n=5+5) wuffs_deflate_decode_10k_part_init/gcc7 276MB/s ± 0% 275MB/s ± 1% ~ (p=0.056 n=5+5) wuffs_deflate_decode_100k_just_one_read/gcc7 322MB/s ± 0% 322MB/s ± 0% ~ (p=0.548 n=5+5) wuffs_deflate_decode_100k_many_big_reads/gcc7 258MB/s ± 0% 258MB/s ± 0% ~ (p=0.056 n=5+5) wuffs_zlib_decode_10k/clang5 212MB/s ± 0% 222MB/s ± 0% +4.59% (p=0.008 n=5+5) wuffs_zlib_decode_100k/clang5 252MB/s ± 1% 247MB/s ± 0% -2.02% (p=0.008 n=5+5) wuffs_zlib_decode_10k/gcc7 248MB/s ± 0% 253MB/s ± 0% +2.00% (p=0.008 n=5+5) wuffs_zlib_decode_100k/gcc7 283MB/s ± 0% 292MB/s ± 0% +3.17% (p=0.008 n=5+5) --- internal/cgen/func.go | 7 ++---- release/c/wuffs-unsupported-snapshot.c | 30 +++++++++++++++++++++++++- 2 files changed, 31 insertions(+), 6 deletions(-) diff --git a/internal/cgen/func.go b/internal/cgen/func.go index 1996e78b..3f8daf54 100644 --- a/internal/cgen/func.go +++ b/internal/cgen/func.go @@ -420,13 +420,10 @@ func (g *gen) writeFuncImplArgChecks(b *buffer, n *a.Func) error { for _, o := range n.In().Fields() { o := o.AsField() oTyp := o.XType() - if oTyp.Decorator() != t.IDPtr && !oTyp.IsRefined() { - // TODO: Also check elements, for array-typed arguments. - continue - } + // TODO: Also check elements, for array-typed arguments. switch { - case oTyp.Decorator() == t.IDPtr: + case oTyp.IsIOType() || (oTyp.Decorator() == t.IDPtr): checks = append(checks, fmt.Sprintf("!%s%s", aPrefix, o.Name().Str(g.tm))) case oTyp.IsRefined(): diff --git a/release/c/wuffs-unsupported-snapshot.c b/release/c/wuffs-unsupported-snapshot.c index 99ed30c6..ebe11549 100644 --- a/release/c/wuffs-unsupported-snapshot.c +++ b/release/c/wuffs-unsupported-snapshot.c @@ -6384,6 +6384,10 @@ wuffs_deflate__decoder__decode_io_writer(wuffs_deflate__decoder* self, ? wuffs_base__error__disabled_by_previous_error : wuffs_base__error__initialize_not_called; } + if (!a_dst || !a_src) { + self->private_impl.magic = WUFFS_BASE__DISABLED; + return wuffs_base__error__bad_argument; + } if ((self->private_impl.active_coroutine != 0) && (self->private_impl.active_coroutine != 1)) { self->private_impl.magic = WUFFS_BASE__DISABLED; @@ -8135,6 +8139,10 @@ wuffs_lzw__decoder__decode_io_writer(wuffs_lzw__decoder* self, ? wuffs_base__error__disabled_by_previous_error : wuffs_base__error__initialize_not_called; } + if (!a_dst || !a_src) { + self->private_impl.magic = WUFFS_BASE__DISABLED; + return wuffs_base__error__bad_argument; + } if ((self->private_impl.active_coroutine != 0) && (self->private_impl.active_coroutine != 1)) { self->private_impl.magic = WUFFS_BASE__DISABLED; @@ -8730,6 +8738,10 @@ wuffs_gif__decoder__decode_image_config(wuffs_gif__decoder* self, ? wuffs_base__error__disabled_by_previous_error : wuffs_base__error__initialize_not_called; } + if (!a_src) { + self->private_impl.magic = WUFFS_BASE__DISABLED; + return wuffs_base__error__bad_argument; + } if ((self->private_impl.active_coroutine != 0) && (self->private_impl.active_coroutine != 1)) { self->private_impl.magic = WUFFS_BASE__DISABLED; @@ -8843,6 +8855,10 @@ wuffs_gif__decoder__ack_metadata_chunk(wuffs_gif__decoder* self, ? wuffs_base__error__disabled_by_previous_error : wuffs_base__error__initialize_not_called; } + if (!a_src) { + self->private_impl.magic = WUFFS_BASE__DISABLED; + return wuffs_base__error__bad_argument; + } if ((self->private_impl.active_coroutine != 0) && (self->private_impl.active_coroutine != 2)) { self->private_impl.magic = WUFFS_BASE__DISABLED; @@ -9097,6 +9113,10 @@ wuffs_gif__decoder__decode_frame_config(wuffs_gif__decoder* self, ? wuffs_base__error__disabled_by_previous_error : wuffs_base__error__initialize_not_called; } + if (!a_src) { + self->private_impl.magic = WUFFS_BASE__DISABLED; + return wuffs_base__error__bad_argument; + } if ((self->private_impl.active_coroutine != 0) && (self->private_impl.active_coroutine != 3)) { self->private_impl.magic = WUFFS_BASE__DISABLED; @@ -9362,7 +9382,7 @@ wuffs_gif__decoder__decode_frame(wuffs_gif__decoder* self, ? wuffs_base__error__disabled_by_previous_error : wuffs_base__error__initialize_not_called; } - if (!a_dst) { + if (!a_dst || !a_src) { self->private_impl.magic = WUFFS_BASE__DISABLED; return wuffs_base__error__bad_argument; } @@ -11263,6 +11283,10 @@ wuffs_gzip__decoder__decode_io_writer(wuffs_gzip__decoder* self, ? wuffs_base__error__disabled_by_previous_error : wuffs_base__error__initialize_not_called; } + if (!a_dst || !a_src) { + self->private_impl.magic = WUFFS_BASE__DISABLED; + return wuffs_base__error__bad_argument; + } if ((self->private_impl.active_coroutine != 0) && (self->private_impl.active_coroutine != 1)) { self->private_impl.magic = WUFFS_BASE__DISABLED; @@ -11740,6 +11764,10 @@ wuffs_zlib__decoder__decode_io_writer(wuffs_zlib__decoder* self, ? wuffs_base__error__disabled_by_previous_error : wuffs_base__error__initialize_not_called; } + if (!a_dst || !a_src) { + self->private_impl.magic = WUFFS_BASE__DISABLED; + return wuffs_base__error__bad_argument; + } if ((self->private_impl.active_coroutine != 0) && (self->private_impl.active_coroutine != 1)) { self->private_impl.magic = WUFFS_BASE__DISABLED;