DLL back data affect App variables?

Dear all,
My App  call the DLL function, it will new DllArray[0x1fff]
and return *DllArray to APP  *AppArray, above step function
verification is ok! (Array define char* ).

But why I will *AppArray write to a file, its handle return -1 ,
file handle and *AppArray both are changed?

-1=write (handle, AppArray,0x1fff);

Is memory leak? or  memory address sharing?
Any sample code can refer to?( need CreatFileMapping or something)