From 57db252783d65e850489833f2a5a80550acd15ad Mon Sep 17 00:00:00 2001 From: William Casarin Date: Fri, 28 Jun 2024 16:41:32 -0500 Subject: [PATCH] nostrdb: ndb_note_json: return length Signed-off-by: William Casarin --- nostrdb/src/nostrdb.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/nostrdb/src/nostrdb.c b/nostrdb/src/nostrdb.c index 5bc01140..17b50ac8 100644 --- a/nostrdb/src/nostrdb.c +++ b/nostrdb/src/nostrdb.c @@ -4756,7 +4756,7 @@ int ndb_note_json(struct ndb_note *note, char *buf, int buflen) make_cursor((unsigned char *)buf, (unsigned char*)buf + buflen, &cur); - return cursor_push_str(c, "{\"id\":\"") && + int ok = cursor_push_str(c, "{\"id\":\"") && cursor_push_hex(c, ndb_note_id(note), 32) && cursor_push_str(c, "\",\"pubkey\":\"") && cursor_push_hex(c, ndb_note_pubkey(note), 32) && @@ -4772,6 +4772,11 @@ int ndb_note_json(struct ndb_note *note, char *buf, int buflen) cursor_push_hex(c, ndb_note_sig(note), 64) && cursor_push_c_str(c, "\"}"); + if (!ok) { + return 0; + } + + return cur.p - cur.start; } int ndb_calculate_id(struct ndb_note *note, unsigned char *buf, int buflen) {