diff --git a/xpcom/base/nsISupportsObsolete.h b/xpcom/base/nsISupportsObsolete.h index ff60154e53e..874d859fbfd 100644 --- a/xpcom/base/nsISupportsObsolete.h +++ b/xpcom/base/nsISupportsObsolete.h @@ -88,21 +88,24 @@ _method(_type aResult) \ * special for strings to get/set char* strings * using PL_strdup and PR_FREEIF */ -#define NS_METHOD_GETTER_STR(_method,_member) \ -_method(char* *aString)\ -{\ +#define NS_METHOD_GETTER_STR(_method,_member) \ +_method(char* *aString) \ +{ \ if (!aString) return NS_ERROR_NULL_POINTER; \ - *aString = PL_strdup(_member); \ - return NS_OK; \ + if (!(*aString = PL_strdup(_member))) \ + return NS_ERROR_OUT_OF_MEMORY; \ + return NS_OK; \ } #define NS_METHOD_SETTER_STR(_method, _member) \ -_method(const char *aString)\ -{\ - PR_FREEIF(_member);\ - if (aString) _member = PL_strdup(aString); \ - else _member = nsnull;\ - return NS_OK; \ +_method(const char *aString) \ +{ \ + if (_member) PR_Free(_member); \ + if (!aString) \ + _member = nsnull; \ + else if (!(_member = PL_strdup(aString))) \ + return NS_ERROR_OUT_OF_MEMORY; \ + return NS_OK; \ } /* Getter/Setter macros.