South African court avoids social security disaster