test_gesture_layer2: add null checking after memory allocation