mirror of
https://github.com/radareorg/radare2.git
synced 2024-12-04 03:11:28 +00:00
Warn when invalid use of r_buf_buffer (#13240)
This commit is contained in:
parent
dae64a0cba
commit
7fdf247e34
@ -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);
|
||||
}
|
||||
|
@ -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) {
|
||||
|
Loading…
Reference in New Issue
Block a user