Bug 1258312 - Add crash annotation to EnumSerializer r?mccr8
MozReview-Commit-ID: DShQTzeFGQc
--- a/ipc/glue/IPCMessageUtils.h
+++ b/ipc/glue/IPCMessageUtils.h
@@ -20,16 +20,19 @@
#ifdef XP_WIN
#include "mozilla/TimeStamp_windows.h"
#endif
#include "mozilla/TypeTraits.h"
#include "mozilla/IntegerTypeTraits.h"
#include <stdint.h>
+#ifdef MOZ_CRASHREPORTER
+#include "nsExceptionHandler.h"
+#endif
#include "nsID.h"
#include "nsIWidget.h"
#include "nsMemory.h"
#include "nsString.h"
#include "nsTArray.h"
#include "js/StructuredClone.h"
#include "nsCSSProperty.h"
@@ -108,18 +111,27 @@ struct EnumSerializer {
static void Write(Message* aMsg, const paramType& aValue) {
MOZ_ASSERT(EnumValidator::IsLegalValue(aValue));
WriteParam(aMsg, uintParamType(aValue));
}
static bool Read(const Message* aMsg, void** aIter, paramType* aResult) {
uintParamType value;
- if(!ReadParam(aMsg, aIter, &value) ||
- !EnumValidator::IsLegalValue(paramType(value))) {
+ if (!ReadParam(aMsg, aIter, &value)) {
+#ifdef MOZ_CRASHREPORTER
+ CrashReporter::AnnotateCrashReport(NS_LITERAL_CSTRING("IPCReadErrorReason"),
+ NS_LITERAL_CSTRING("Bad iter"));
+#endif
+ return false;
+ } else if (!EnumValidator::IsLegalValue(paramType(value))) {
+#ifdef MOZ_CRASHREPORTER
+ CrashReporter::AnnotateCrashReport(NS_LITERAL_CSTRING("IPCReadErrorReason"),
+ NS_LITERAL_CSTRING("Illegal value"));
+#endif
return false;
}
*aResult = paramType(value);
return true;
}
};
template <typename E,