Fix getBuffer problem.
authorWonkyu Kwon <wonkyu.kwon@samsung.com>
Thu, 18 Jul 2013 06:26:30 +0000 (15:26 +0900)
committerWonkyu Kwon <wonkyu.kwon@samsung.com>
Wed, 24 Jul 2013 08:56:38 +0000 (17:56 +0900)
Change-Id: Ifc0a4bf3493c86e1936e35a04e9b5f20395056a1

common/ByteArray.cpp
common/include/ByteArray.h

index b41c098..0f26704 100644 (file)
@@ -97,6 +97,11 @@ namespace smartcard_service_api
                return getBuffer(0);
        }
 
+       const uint8_t *ByteArray::getBuffer() const
+       {
+               return getBuffer(0);
+       }
+
        uint8_t *ByteArray::getBuffer(size_t offset)
        {
                if (length == 0)
@@ -111,6 +116,20 @@ namespace smartcard_service_api
                return buffer + offset;
        }
 
+       const uint8_t *ByteArray::getBuffer(size_t offset) const
+       {
+               if (length == 0)
+                       return NULL;
+
+               if (offset >= length)
+               {
+                       _ERR("buffer overflow, offset [%d], length [%d]", offset, length);
+                       return NULL;
+               }
+
+               return buffer + offset;
+       }
+
        uint8_t ByteArray::at(size_t index) const
        {
                if (index >= length)
index 72e0054..e35bef0 100644 (file)
@@ -60,9 +60,9 @@ namespace smartcard_service_api
                size_t size() const;
                inline size_t getLength() const { return size(); }
                uint8_t *getBuffer();
-               inline const uint8_t *getBuffer() const { return getBuffer(); }
+               const uint8_t *getBuffer() const;
                uint8_t *getBuffer(size_t offset);
-               inline const uint8_t *getBuffer(size_t offset) const { return getBuffer(offset); }
+               const uint8_t *getBuffer(size_t offset) const;
 
                uint8_t at(size_t index) const;
                uint8_t reverseAt(size_t index) const;