Avoid segfaults when an invalid dynamic class is used in the 'new' operator