libdatasource: fix null dereference
mediaHTTP can be NULL when failed to make http connection
from http service, and then mediaHTTP->connect() will crash.
check if mediaHTTP is NULL before calling mediaHTTP->connect().
Bug: 186381982
Change-Id: I936baf9fbbb2001f8f48f0f1c15f6bc08513600a
Test: http streaming ut
diff --git a/media/libdatasource/DataSourceFactory.cpp b/media/libdatasource/DataSourceFactory.cpp
index bb6a08c..f91e3ea 100644
--- a/media/libdatasource/DataSourceFactory.cpp
+++ b/media/libdatasource/DataSourceFactory.cpp
@@ -65,6 +65,9 @@
sp<HTTPBase> mediaHTTP = httpSource;
if (mediaHTTP == NULL) {
mediaHTTP = static_cast<HTTPBase *>(CreateMediaHTTP(httpService).get());
+ if (mediaHTTP == NULL) {
+ return NULL;
+ }
}
String8 cacheConfig;