Clipboard: fix integer underflow 84/262584/1
authorBowon Ryu <bowon.ryu@samsung.com>
Fri, 13 Aug 2021 09:56:35 +0000 (18:56 +0900)
committerBowon Ryu <bowon.ryu@samsung.com>
Fri, 13 Aug 2021 09:56:35 +0000 (18:56 +0900)
GetCount() returns an int, but NumberOfItems() returns an unsigned int.
If GetCount() returns a negative number, NumberOfItems() may return an unintended value.
There is also the risk of underflow.

Change-Id: I8db63963257c616b7a281c14b1c8f2480fbdc91e
Signed-off-by: Bowon Ryu <bowon.ryu@samsung.com>
dali/internal/clipboard/tizen-wayland/clipboard-impl-ecore-wl.cpp

index 15aa6a5..b54da7d 100644 (file)
@@ -307,7 +307,8 @@ void Clipboard::RequestItem()
  */
 unsigned int Clipboard::NumberOfItems()
 {
-  return mImpl->GetCount();
+  int count = mImpl->GetCount();
+  return (count < 0 ? 0 : count);
 }
 
 void Clipboard::ShowClipboard()