If caller passed the size of array not string length, it is possible to be accessed out of bounds.
Reorder conditions can prevent access invalid index of array.
Signed-off-by: 2xsec <dh48.jeong@samsung.com>
if (offset >= fulllen)
return NULL;
- while (path[offset] != '\0' && offset < fulllen)
+ while (offset < fulllen && path[offset] != '\0')
offset++;
- while (path[offset] == '\0' && offset < fulllen)
+ while (offset < fulllen && path[offset] == '\0')
offset++;
*offsetp = offset;