viz: fixed memory leak (2.4)

Viz module: fixed memory leak (2.4 branch)
http://code.opencv.org/issues/3961