commit 27071064d2aba91ac9c656821b66c626eb76f711 from: Omar Polo via: Thomas Adam date: Tue Dec 19 17:12:50 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 - 8cbbef47c4779325cf718162b688c5bedab91c30 commit + 27071064d2aba91ac9c656821b66c626eb76f711 blob - 9b91e1cb784c24ba70086d4bc32c0f1fd0fec02a blob + 81b7bad406a36077c723a1b900eb1b2b66db898e --- lib/pack.c +++ lib/pack.c @@ -671,8 +671,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); @@ -703,16 +701,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