- if (!n->curr_backrefs) {
- int sz=sizeof( struct yaz_nfa_backref_info);
- n->curr_backrefs=nmem_malloc( n->nmem, n->nbackrefs* sz);
- n->best_backrefs=nmem_malloc( n->nmem, n->nbackrefs* sz);
+ if ((!n->curr_backrefs) && (n->nbackrefs)){
+ int sz=sizeof( struct yaz_nfa_backref_info) * (n->nbackrefs+1);
+ n->curr_backrefs=nmem_malloc( n->nmem, sz);
+ n->best_backrefs=nmem_malloc( n->nmem, sz);