Bug 1258312 - Add crash annotation to EnumSerializer r?mccr8 draft
authorKan-Ru Chen <kanru@kanru.info>
Wed, 30 Mar 2016 12:32:26 +0800
changeset 345698 d7afeda6f1a5eb4035212a6408e234560676d010
parent 345697 07b5b7952f4c93103d753ec7142cc15252dc1f86
child 517245 1578512155a2216e5c81fa389474701d2a46fe41
push id14146
push userbmo:kchen@mozilla.com
push dateWed, 30 Mar 2016 04:34:09 +0000
reviewersmccr8
bugs1258312
milestone48.0a1
Bug 1258312 - Add crash annotation to EnumSerializer r?mccr8 MozReview-Commit-ID: DShQTzeFGQc
ipc/glue/IPCMessageUtils.h
--- 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,