diff --git a/src/input/Manager.cc b/src/input/Manager.cc index bd6cd34991..6b179f66a1 100644 --- a/src/input/Manager.cc +++ b/src/input/Manager.cc @@ -750,7 +750,7 @@ Val* Manager::RecordValToIndexVal(RecordVal *r) { int num_fields = type->NumFields(); if ( num_fields == 1 && type->FieldDecl(0)->type->Tag() != TYPE_RECORD ) { - idxval = r->Lookup(0); + idxval = r->LookupWithDefault(0); } else { ListVal *l = new ListVal(TYPE_ANY); for ( int j = 0 ; j < num_fields; j++ ) { @@ -902,6 +902,7 @@ int Manager::SendEntryTable(Stream* i, const Value* const *vals) { if ( result == false ) { Unref(predidx); + Unref(valval); if ( !updated ) { // throw away. Hence - we quit. And remove the entry from the current dictionary... // (but why should it be in there? assert this). @@ -956,6 +957,9 @@ int Manager::SendEntryTable(Stream* i, const Value* const *vals) { Ref(oldval); // otherwise it is no longer accessible after the assignment filter->tab->Assign(idxval, k, valval); Unref(idxval); // asssign does not consume idxval. + if ( predidx != 0 ) { + Unref(predidx); + } filter->currDict->Insert(idxhash, ih); delete idxhash; diff --git a/src/input/readers/Ascii.cc b/src/input/readers/Ascii.cc index a1119ed253..a167408a0e 100644 --- a/src/input/readers/Ascii.cc +++ b/src/input/readers/Ascii.cc @@ -101,12 +101,16 @@ bool Ascii::DoInit(string path, int arg_mode, int arg_num_fields, const Field* c file = new ifstream(path.c_str()); if ( !file->is_open() ) { Error(Fmt("Init: cannot open %s", fname.c_str())); + delete(file); + file = 0; return false; } if ( ReadHeader(false) == false ) { Error(Fmt("Init: cannot open %s; headers are incorrect", fname.c_str())); file->close(); + delete(file); + file = 0; return false; }