Fix memory leak in default index group creation

Temporary memory should be deallocated in the scope where it is
allocated, not only within some conditional paths.

Change-Id: I102d2b82ba531c25dd26728729b46c0b99c124e4