vfs: check userland buffers before reading them.
[haiku.git] / src / servers / app / drawing / BitmapBuffer.cpp
blob994e3a51e1a8ef9bec081e4eff9e90ec5298a4c4
1 // BitmapBuffer.h
3 #include "ServerBitmap.h"
5 #include "BitmapBuffer.h"
7 // TODO: It should be more or less guaranteed that this object
8 // is not used if InitCheck() returns an error, so the checks
9 // in all thos functions should probably be removed...
11 // constructor
12 BitmapBuffer::BitmapBuffer(ServerBitmap* bitmap)
13 : fBitmap(bitmap)
17 // destructor
18 BitmapBuffer::~BitmapBuffer()
20 // We don't own the ServerBitmap
23 // InitCheck
24 status_t
25 BitmapBuffer::InitCheck() const
27 status_t ret = B_NO_INIT;
28 if (fBitmap)
29 ret = fBitmap->IsValid() ? B_OK : B_ERROR;
30 return ret;
33 // ColorSpace
34 color_space
35 BitmapBuffer::ColorSpace() const
37 if (InitCheck() >= B_OK)
38 return fBitmap->ColorSpace();
39 return B_NO_COLOR_SPACE;
42 // Bits
43 void*
44 BitmapBuffer::Bits() const
46 if (InitCheck() >= B_OK)
47 return fBitmap->Bits();
48 return NULL;
51 // BytesPerRow
52 uint32
53 BitmapBuffer::BytesPerRow() const
55 if (InitCheck() >= B_OK)
56 return fBitmap->BytesPerRow();
57 return 0;
60 // Width
61 uint32
62 BitmapBuffer::Width() const
64 if (InitCheck() >= B_OK)
65 return fBitmap->Width();
66 return 0;
69 // Height
70 uint32
71 BitmapBuffer::Height() const
73 if (InitCheck() >= B_OK)
74 return fBitmap->Height();
75 return 0;