make sure parameter is not negative

- fixes coverity issue 1198843 Argument cannot be negative