Skip to content

Commit

Permalink
BufferCache: More strict validity checks
Browse files Browse the repository at this point in the history
* This add a debugger call if the BBuffer id is
mismatched at object creation.
  • Loading branch information
Numerio committed Nov 28, 2015
1 parent 6706066 commit d98b8c7
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/kits/media/BufferCache.cpp
Expand Up @@ -45,11 +45,15 @@ BufferCache::GetBuffer(media_buffer_id id)
buffer_clone_info info;
info.buffer = id;
BBuffer* buffer = new(std::nothrow) BBuffer(info);
if (buffer == NULL || buffer->Data() == NULL) {
if (buffer == NULL || buffer->ID() <= 0
|| buffer->Data() == NULL) {
delete buffer;
return NULL;
}

if (buffer->ID() != id)
debugger("BufferCache::GetBuffer: IDs mismatch");

try {
fMap.insert(std::make_pair(id, buffer));
} catch (std::bad_alloc& exception) {
Expand Down

0 comments on commit d98b8c7

Please sign in to comment.