webm_info: avoid null deref w/track->GetCodecId()
check pointer value before converting to string
BUG=webm:1605
Change-Id: I81c1d90517e12c90fc1e3c3c753e273360c9de38
diff --git a/webm_info.cc b/webm_info.cc
index cf70d7b..88aee17 100644
--- a/webm_info.cc
+++ b/webm_info.cc
@@ -177,6 +177,8 @@
return wstr;
}
+string ToString(const char* str) { return string((str == NULL) ? "" : str); }
+
void OutputEBMLHeader(const mkvparser::EBMLHeader& ebml, FILE* o,
Indent* indent) {
fprintf(o, "EBML Header:\n");
@@ -376,7 +378,7 @@
static_cast<int>(private_size));
if (track_type == mkvparser::Track::kVideo) {
- const std::string codec_id = track->GetCodecId();
+ const std::string codec_id = ToString(track->GetCodecId());
const std::string v_vp9 = "V_VP9";
if (codec_id == v_vp9) {
libwebm::Vp9CodecFeatures features;
@@ -1018,7 +1020,7 @@
data += frame_offset;
frame_size -= frame_offset;
- const string codec_id = track->GetCodecId();
+ const string codec_id = ToString(track->GetCodecId());
if (codec_id == "V_VP8") {
PrintVP8Info(data, frame_size, o);
} else if (codec_id == "V_VP9") {