diff --git a/libr/io/p/io_gprobe.c b/libr/io/p/io_gprobe.c index ae69141588..1f29399709 100644 --- a/libr/io/p/io_gprobe.c +++ b/libr/io/p/io_gprobe.c @@ -95,12 +95,11 @@ static ut8 gprobe_checksum_i2c (const ut8 *p, unsigned int size, ut8 initial) { static void gprobe_frame_i2c (RBuffer *frame) { ut8 size = r_buf_size (frame) + 1; ut8 header[] = {0x51, 0x80 + size + 3, 0xc2, 0x00, 0x00}; - ut8 checksum; r_buf_prepend_bytes (frame, &size, 1); r_buf_prepend_bytes (frame, header, sizeof (header)); - checksum = gprobe_checksum_i2c (r_buf_buffer (frame), r_buf_size (frame), GPROBE_I2C_ADDR); + ut8 checksum = gprobe_checksum_i2c (r_buf_buffer (frame), r_buf_size (frame), GPROBE_I2C_ADDR); r_buf_append_bytes (frame, &checksum, 1); } diff --git a/libr/util/buf.c b/libr/util/buf.c index e55001dcbf..d9f2c3e257 100644 --- a/libr/util/buf.c +++ b/libr/util/buf.c @@ -402,7 +402,10 @@ R_API RBuffer *r_buf_new() { } R_API const ut8 *r_buf_buffer (RBuffer *b) { - return (b && !b->sparse)? b->buf: NULL; + if (b && !b->sparse && b->fd == -1 && !b->mmap) { + return b->buf; + } + r_return_val_if_fail (false, NULL); } R_API ut64 r_buf_size (RBuffer *b) {