Fix coverity issues (uint32_t overflow + size_t to int32_t)