diff --git a/ChangeLog b/ChangeLog index e97a7686d2..c7d4c3e92f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,21 @@ 2004-01-06 Derek Atkins + * src/engine/qofinstance.c: revert fix from 01-01, because it's wrong. + Fix the actual problem, all the ...ReturnGUID() #define's which + don't check that it's passed a NULL value. + * src/engine/Transaction.h: + * src/engine/Account.h: + Fix ...ReturnGUID() to check whether it was passed a NULL object + and, if so, return the null GUID instead of crashing. + * src/business/business-core/gncCustomer.h: + * src/business/business-core/gncEmployee.h: + * src/business/business-core/gncInvoice.h: + * src/business/business-core/gncJob.h: + * src/business/business-core/gncTaxTable.h: + * src/business/business-core/gncVendor.h: + Fix ...RetGUID() to check whether it was passed a NULL object + and, if so, return the null GUID instead of crashing. + * README.cvs: make it even more explicit that you should not run configure * src/engine/Makefile.am: remove the circular dependency I added earlier * src/engine/gw-engine-spec.scm: don't include gnc-engine-util.h (it's diff --git a/src/business/business-core/gncCustomer.h b/src/business/business-core/gncCustomer.h index ee9fe90259..0d62296a39 100644 --- a/src/business/business-core/gncCustomer.h +++ b/src/business/business-core/gncCustomer.h @@ -111,7 +111,7 @@ int gncCustomerCompare (GncCustomer *a, GncCustomer *b); /* deprecated functions, should be removed */ #define gncCustomerGetGUID(x) qof_instance_get_guid(QOF_INSTANCE(x)) -#define gncCustomerRetGUID(x) (*(qof_instance_get_guid(QOF_INSTANCE(x)))) +#define gncCustomerRetGUID(x) (x ? *(qof_instance_get_guid(QOF_INSTANCE(x))) : *(guid_null())) #define gncCustomerGetBook(x) qof_instance_get_book(QOF_INSTANCE(x)) #define gncCustomerLookupDirect(g,b) gncCustomerLookup((b), &(g)) diff --git a/src/business/business-core/gncEmployee.h b/src/business/business-core/gncEmployee.h index 67b714aab0..e1e019824a 100644 --- a/src/business/business-core/gncEmployee.h +++ b/src/business/business-core/gncEmployee.h @@ -94,7 +94,7 @@ int gncEmployeeCompare (GncEmployee *a, GncEmployee *b); /** deprecated routines */ #define gncEmployeeGetGUID(E) qof_entity_get_guid(QOF_ENTITY(E)) -#define gncEmployeeRetGUID(E) (*(qof_entity_get_guid(QOF_ENTITY(E)))) +#define gncEmployeeRetGUID(E) (E ? *(qof_entity_get_guid(QOF_ENTITY(E))) : *(guid_null())) #define gncEmployeeLookupDirect(G,B) gncEmployeeLookup((B),&(G)) #endif /* GNC_EMPLOYEE_H_ */ diff --git a/src/business/business-core/gncInvoice.h b/src/business/business-core/gncInvoice.h index 8aef82781e..e862d37d00 100644 --- a/src/business/business-core/gncInvoice.h +++ b/src/business/business-core/gncInvoice.h @@ -177,7 +177,7 @@ gboolean gncInvoiceIsPaid (GncInvoice *invoice); /** deprecated functions */ #define gncInvoiceGetBook(x) qof_instance_get_book(QOF_INSTANCE(x)) #define gncInvoiceGetGUID(x) qof_instance_get_guid(QOF_INSTANCE(x)) -#define gncInvoiceRetGUID(x) (*(qof_instance_get_guid(QOF_INSTANCE(x)))) +#define gncInvoiceRetGUID(x) (x ? *(qof_instance_get_guid(QOF_INSTANCE(x))) : *(guid_null())) #define gncInvoiceLookupDirect(G,B) gncInvoiceLookup((B),&(G)) #endif /* GNC_INVOICE_H_ */ diff --git a/src/business/business-core/gncJob.h b/src/business/business-core/gncJob.h index 97d1da65b8..a676d441a3 100644 --- a/src/business/business-core/gncJob.h +++ b/src/business/business-core/gncJob.h @@ -86,7 +86,7 @@ int gncJobCompare (const GncJob *a, const GncJob *b); /** deprecated functions */ #define gncJobGetBook(x) qof_instance_get_book(QOF_INSTANCE(x)) #define gncJobGetGUID(x) qof_instance_get_guid(QOF_INSTANCE(x)) -#define gncJobRetGUID(x) (*(qof_instance_get_guid(QOF_INSTANCE(x)))) +#define gncJobRetGUID(x) (x ? *(qof_instance_get_guid(QOF_INSTANCE(x))) : *(guid_null())) #define gncJobLookupDirect(G,B) gncJobLookup((B),&(G)) #endif /* GNC_JOB_H_ */ diff --git a/src/business/business-core/gncTaxTable.h b/src/business/business-core/gncTaxTable.h index 7685c1776e..96b5d9ecee 100644 --- a/src/business/business-core/gncTaxTable.h +++ b/src/business/business-core/gncTaxTable.h @@ -143,7 +143,7 @@ void gncAccountValueDestroy (GList *list); /** deprecated routine */ #define gncTaxTableGetGUID(x) qof_instance_get_guid(QOF_INSTANCE(x)) -#define gncTaxTableRetGUID(x) (*(qof_instance_get_guid(QOF_INSTANCE(x)))) +#define gncTaxTableRetGUID(x) (x ? *(qof_instance_get_guid(QOF_INSTANCE(x))) : *(guid_null())) #define gncTaxTableLookupDirect(G,B) gncTaxTableLookup((B), &(G)) #endif /* GNC_TAXTABLE_H_ */ diff --git a/src/business/business-core/gncVendor.h b/src/business/business-core/gncVendor.h index 6d547ad282..da0d4c8245 100644 --- a/src/business/business-core/gncVendor.h +++ b/src/business/business-core/gncVendor.h @@ -103,7 +103,7 @@ int gncVendorCompare (GncVendor *a, GncVendor *b); /** deprecated functions */ #define gncVendorGetBook(X) qof_instance_get_book (QOF_INSTANCE(X)) #define gncVendorGetGUID(X) qof_instance_get_guid (QOF_INSTANCE(X)) -#define gncVendorRetGUID(X) (*(qof_instance_get_guid (QOF_INSTANCE(X)))) +#define gncVendorRetGUID(X) (X ? *(qof_instance_get_guid (QOF_INSTANCE(X))) : *(guid_null())) #define gncVendorLookupDirect(G,B) gncVendorLookup((B),&(G)) #endif /* GNC_VENDOR_H_ */ diff --git a/src/engine/Account.h b/src/engine/Account.h index f5e6f8c1e8..b5f9897d8e 100644 --- a/src/engine/Account.h +++ b/src/engine/Account.h @@ -166,7 +166,7 @@ int xaccAccountOrder (Account **account_1, Account **account_2); /** deprecated */ #define xaccAccountGetBook(X) qof_instance_get_book(QOF_INSTANCE(X)) #define xaccAccountGetGUID(X) qof_entity_get_guid(QOF_ENTITY(X)) -#define xaccAccountReturnGUID(X) (*(qof_entity_get_guid(QOF_ENTITY(X)))) +#define xaccAccountReturnGUID(X) (X ? *(qof_entity_get_guid(QOF_ENTITY(X))) : *(guid_null())) /** The xaccAccountLookup() subroutine will return the * account associated with the given id, or NULL diff --git a/src/engine/Transaction.h b/src/engine/Transaction.h index 5c3b155114..e58d40a427 100644 --- a/src/engine/Transaction.h +++ b/src/engine/Transaction.h @@ -859,10 +859,10 @@ Timespec xaccTransGetVoidTime(const Transaction *tr); /** deprecated rouitines */ #define xaccSplitGetGUID(X) qof_entity_get_guid(QOF_ENTITY(X)) -#define xaccSplitReturnGUID(X) (*(qof_entity_get_guid(QOF_ENTITY(X)))) +#define xaccSplitReturnGUID(X) (X ? *(qof_entity_get_guid(QOF_ENTITY(X))) : *(guid_null())) #define xaccTransGetBook(X) qof_instance_get_book (QOF_INSTANCE(X)) #define xaccTransGetGUID(X) qof_entity_get_guid(QOF_ENTITY(X)) -#define xaccTransReturnGUID(X) (*(qof_entity_get_guid(QOF_ENTITY(X)))) +#define xaccTransReturnGUID(X) (X ? *(qof_entity_get_guid(QOF_ENTITY(X))) : *(guid_null())) #define xaccTransGetSlots(X) qof_instance_get_slots (QOF_INSTANCE(X)) #endif /* XACC_TRANSACTION_H */ diff --git a/src/engine/qofinstance.c b/src/engine/qofinstance.c index d192221c70..26c69e61a4 100644 --- a/src/engine/qofinstance.c +++ b/src/engine/qofinstance.c @@ -69,7 +69,7 @@ qof_instance_release (QofInstance *inst) const GUID * qof_instance_get_guid (QofInstance *inst) { - if (!inst) return guid_null(); /* some callers depend on a real return value */ + if (!inst) return NULL; return &inst->entity.guid; }