With my changes 2 toCBuffer methods assume hgs to be not null. And up to this change in doc.c which was 2 days ago hgs was always not null. So I changed this code instead of littering the toCBuffer code with additional ifs.