From 971fa3e4ef00fb745b00b7416341fe4eb28739ed Mon Sep 17 00:00:00 2001 From: William Casarin Date: Fri, 29 Dec 2023 09:38:34 -0800 Subject: [PATCH] nostrdb/invoice: fix crash in any-amount invoice parsing Signed-off-by: William Casarin --- nostrdb/src/invoice.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/nostrdb/src/invoice.c b/nostrdb/src/invoice.c index 8bfca0dd..622a290d 100644 --- a/nostrdb/src/invoice.c +++ b/nostrdb/src/invoice.c @@ -11,8 +11,7 @@ int ndb_encode_invoice(struct cursor *cur, struct bolt11 *invoice) { if (!cursor_push_byte(cur, 1)) return 0; - // TODO: make cursor_cursor_push_varint uint64_t - if (!cursor_push_varint(cur, invoice->msat->millisatoshis)) + if (!cursor_push_varint(cur, invoice->msat == NULL ? 0 : invoice->msat->millisatoshis)) return 0; if (!cursor_push_varint(cur, invoice->timestamp))