diff options
| author | Igor Pashev <pashev.igor@gmail.com> | 2012-04-26 14:30:56 +0400 |
|---|---|---|
| committer | Igor Pashev <pashev.igor@gmail.com> | 2012-04-26 14:30:56 +0400 |
| commit | 33c566e087d14b7399f585c66084a50638d0affb (patch) | |
| tree | 3675dd42208186a9f611c2231d4fc399a9ad5f8e | |
| parent | c37f95899f4c409cee9b68efd6dd8a792d0b20df (diff) | |
| download | node-augeas-33c566e087d14b7399f585c66084a50638d0affb.tar.gz | |
matches can be NULL
| -rw-r--r-- | libaugeas.cc | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/libaugeas.cc b/libaugeas.cc index 76424e8..1800f8b 100644 --- a/libaugeas.cc +++ b/libaugeas.cc @@ -494,13 +494,14 @@ Handle<Value> LibAugeas::match(const Arguments& args) int rc = aug_match(obj->m_aug, path, &matches); if (rc >= 0) { - assert(matches != NULL); Local<Array> result = Array::New(rc); - for (int i = 0; i < rc; ++i) { - result->Set(Number::New(i), String::New(matches[i])); - free(matches[i]); + if (NULL != matches) { + for (int i = 0; i < rc; ++i) { + result->Set(Number::New(i), String::New(matches[i])); + free(matches[i]); + } + free(matches); } - free(matches); return scope.Close(result); } else { throw_aug_error_msg(obj->m_aug); |
