mirror of
https://github.com/Mathewnd/Astral.git
synced 2026-11-01 15:08:21 +00:00
framebuffer: handle an edge case
This commit is contained in:
@@ -18,6 +18,10 @@ static int devchecks(int fb, size_t* count, size_t offset){
|
|||||||
|
|
||||||
size_t end = fbs[fb]->pitch * fbs[fb]->height;
|
size_t end = fbs[fb]->pitch * fbs[fb]->height;
|
||||||
|
|
||||||
|
if(offset >= end){
|
||||||
|
*count = 0;
|
||||||
|
}
|
||||||
|
|
||||||
if(*count + offset > end)
|
if(*count + offset > end)
|
||||||
*count = end - offset;
|
*count = end - offset;
|
||||||
|
|
||||||
@@ -32,9 +36,9 @@ int read(int* error, int minor, void* buff, size_t count, size_t offset){
|
|||||||
|
|
||||||
if(*error)
|
if(*error)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
memcpy(buff, fbs[minor]->address + offset, count);
|
memcpy(buff, fbs[minor]->address + offset, count);
|
||||||
|
|
||||||
return count;
|
return count;
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -45,7 +49,7 @@ int write(int* error, int minor, void* buff, size_t count, size_t offset){
|
|||||||
|
|
||||||
if(*error)
|
if(*error)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
memcpy(fbs[minor]->address + offset, buff, count);
|
memcpy(fbs[minor]->address + offset, buff, count);
|
||||||
|
|
||||||
return count;
|
return count;
|
||||||
|
|||||||
Reference in New Issue
Block a user