We use NULL to mean "unknown source", but you can't pass NULL to C string functions.
Found by the stability monkeys.
Bug: 5880980
Change-Id: I2775024a5038d3716f4e7c6beac02c3f5e0a3f3a
diff --git a/src/monitor.cc b/src/monitor.cc
index caaa116..b641160 100644
--- a/src/monitor.cc
+++ b/src/monitor.cc
@@ -800,12 +800,15 @@
const char*& source_file, uint32_t& line_number) const {
// If method is null, location is unknown
if (method == NULL) {
- source_file = "unknown";
+ source_file = "";
line_number = 0;
return;
}
MethodHelper mh(method);
source_file = mh.GetDeclaringClassSourceFile();
+ if (source_file == NULL) {
+ source_file = "";
+ }
line_number = mh.GetLineNumFromNativePC(pc);
}
diff --git a/src/object_utils.h b/src/object_utils.h
index 0412858..3af7007 100644
--- a/src/object_utils.h
+++ b/src/object_utils.h
@@ -169,11 +169,8 @@
std::string descriptor(GetDescriptor());
const DexFile& dex_file = GetDexFile();
const DexFile::ClassDef* dex_class_def = dex_file.FindClassDef(descriptor);
- if (dex_class_def == NULL) {
- return NULL;
- } else {
- return dex_file.GetSourceFile(*dex_class_def);
- }
+ CHECK(dex_class_def != NULL);
+ return dex_file.GetSourceFile(*dex_class_def);
}
std::string GetLocation() {
@@ -477,11 +474,8 @@
const char* descriptor = GetDeclaringClassDescriptor();
const DexFile& dex_file = GetDexFile();
const DexFile::ClassDef* dex_class_def = dex_file.FindClassDef(descriptor);
- if (dex_class_def == NULL) {
- return NULL;
- } else {
- return dex_file.GetSourceFile(*dex_class_def);
- }
+ CHECK(dex_class_def != NULL);
+ return dex_file.GetSourceFile(*dex_class_def);
}
bool IsStatic() {
return method_->IsStatic();