Fix reallocation of D buffer in gemm

Conflicts:
	modules/core/src/matmul.cpp
Merge pull request #3108 from LeszekSwirski:fix-gemm-buf-allocate-2.4