commit 6df9defae8435fe7d577ea00350be7db66ee5d2b from: Omar Polo date: Tue Dec 19 13:28:17 2023 UTC change got_packidx_match_id_str_prefix not to reset the stailq Since it appends to the given stailq, the ownership is moved and so don't initialize/reset it at the start and neither on error. The caller has to take care of the contents. (kind of) follow up to 2234939fb4. Based upon an original diff from jamsek; ok jamsek commit - 85467924748b0e27f0105bde280878a149df9fc8 commit + 6df9defae8435fe7d577ea00350be7db66ee5d2b blob - 76eb2dde64f751aa977e37a5be06c8601f1fc0e3 blob + f347f506f5945b7404cc0c48620474bfe6f179a5 --- lib/pack.c +++ lib/pack.c @@ -674,8 +674,6 @@ got_packidx_match_id_str_prefix(struct got_object_id_q size_t prefix_len = strlen(id_str_prefix); struct got_packidx_object_id *oid; uint32_t i = 0; - - STAILQ_INIT(matched_ids); if (prefix_len < 2) return got_error_path(id_str_prefix, GOT_ERR_BAD_OBJ_ID_STR); @@ -706,16 +704,14 @@ got_packidx_match_id_str_prefix(struct got_object_id_q err = got_object_qid_alloc_partial(&qid); if (err) - break; + return err; memcpy(qid->id.sha1, oid->sha1, SHA1_DIGEST_LENGTH); STAILQ_INSERT_TAIL(matched_ids, qid, entry); oid = &packidx->hdr.sorted_ids[++i]; } - if (err) - got_object_id_queue_free(matched_ids); - return err; + return NULL; } static void