Add custom mathlib to TAdvSpreadGrid in code

I am trying to add a custom math library to a TAdvSpreadGrid in code.

I am using the following C++Builder snippet

TCustomMath *FCustomMath = new TCustomMath(form);
TLibBinder *Binder = new TLibBinder(form);
Binder->Libs->Items[0]->MathLib = FCustomMath;
form->FAdvSpreadGrid->Libs = Binder;

This functions but I am seeing intermittent memory access failures when I write to FAdvSpreadGrid->Cells[0][0] after I run the code.

I would like to confirm that this the correct procedure.

The setup of the library binder and library itself looks correct.

Do you have more details on the specific circumstances when the memory access error happens or do you have some sample source project with which we can reproduce this?
Also, are you sure that the lib & binder you created aren't being destroyed by its owner before the grid would still try to use it?