Hello! At Object.h we have two macros: #define OBJECT_TYPE_CHECK(wanted_type) \ if (unlikely(type != wanted_type)) { \ error(0, "Call to Object where the object was type %d, " \ "not the expected type %d", type, wanted_type); \ abort(); \ } #define OBJECT_2TYPES_CHECK(wanted_type1, wanted_type2) \ if (unlikely(type != wanted_type1) && unlikely(type != wanted_type2)) { \ error(0, "Call to Object where the object was type %d, " \ "not the expected type %d or %d", type, wanted_type1, wanted_type2); \ abort(); \ } The purpose of these macros is obvious. But, in case of type inconsistency it is too stiff to abort the WHOLE hosting application. I suggest handling it either using template functions or treatment per case. For example: Instead of: Dict *getDict() { OBJECT_TYPE_CHECK(objDict); return dict; } Dict *getDict() { if (unlikely(type != wanted_type)) { error(0, "Call to Object where the object was type %d, " "not the expected type %d", type, wanted_type); return NULL; } return dict; } Please, let me know if this approach is acceptable to you, and if “yes” I can supply the patch. Regards, Ilya Gorenbein
No, patch is not acceptable. Your patch still will take down the whole application, you are returning a NULL pointer that will make poppler crash. If you found any place where this is happening just fix it the proper way, that is calling the isFoo before getFoo.
Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.