Fix crash in v4l2 plugin.
This adds checks to make sure munmap and bfree are only called when there was actually memory mapped and allocated.master
parent
d73d2b22f8
commit
cd6d2eb9b6
|
@ -111,12 +111,14 @@ int_fast32_t v4l2_create_mmap(int_fast32_t dev, struct v4l2_buffer_data *buf)
|
|||
int_fast32_t v4l2_destroy_mmap(struct v4l2_buffer_data *buf)
|
||||
{
|
||||
for(uint_fast32_t i = 0; i < buf->count; ++i) {
|
||||
if (buf->info[i].start != MAP_FAILED)
|
||||
if (buf->info[i].start != MAP_FAILED && buf->info[i].start != 0)
|
||||
v4l2_munmap(buf->info[i].start, buf->info[i].length);
|
||||
}
|
||||
|
||||
buf->count = 0;
|
||||
bfree(buf->info);
|
||||
if (buf->count) {
|
||||
bfree(buf->info);
|
||||
buf->count = 0;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue