- xr = make_xref_node();
- xr->xref.type = xref_type;
- xr->xref.string = strdup(raw_value);
- hash_alloc_insert(xrefs, key, xr);
+ if (key) {
+ xr = make_xref_node();
+ xr->xref.type = xref_type;
+ if (xr->xref.string)
+ free(xr->xref.string);
+ xr->xref.string = strdup(raw_value);
+ if (! xr->xref.string) MEMORY_ERROR;
+ hash_alloc_insert(xrefs, key, xr);
+ }
+ else
+ MEMORY_ERROR;