Master's branch version of bugfix corrected in pull request #3235

Equivalent bug in the master branch of the bug corrected in 2.4 there https://github.com/Itseez/opencv/pull/3235

Not sure that's how I should do it (another pull request for the same small bug in different branch), but I prefer to do it now that I still remember about it :P