Skip to content

Commit

Permalink
emperor_mongodb: don't segfault in mongo::fromjson if uems->default i…
Browse files Browse the repository at this point in the history
…s NULL

Based on a patch by Hao Wu
  • Loading branch information
xrmx committed Oct 14, 2015
1 parent 7019899 commit 71d6572
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions plugins/emperor_mongodb/emperor_mongodb.cc
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ extern "C" void uwsgi_imperial_monitor_mongodb(struct uwsgi_emperor_scanner *ues
}
mongo::BSONObj p = builder.obj();
mongo::BSONObj q = mongo::fromjson(uems->json);
mongo::BSONObj d = mongo::fromjson(uems->defaults);
mongo::BSONObj d = uems->defaults ? mongo::fromjson(uems->defaults) : mongo::BSONObj();

std::unique_ptr<mongo::DBClientBase> conn;

Expand Down Expand Up @@ -102,7 +102,7 @@ extern "C" void uwsgi_imperial_monitor_mongodb(struct uwsgi_emperor_scanner *ues
const char *attr_value = p.getStringField(e_attrs->value);
if (strlen(attr_value) == 0) attr_value = NULL;

if (!attr_value) {
if (!attr_value && uems->defaults) {
mongo::BSONElement tmp = d.getField(e_attrs->value);

if (tmp.type() == mongo::Array) {
Expand Down

0 comments on commit 71d6572

Please sign in to comment.