Commit 5b859d1
committed
remote-curl: fix memory leak in discover_refs() error paths
When discover_refs() encounters an HTTP error, it calls
show_http_message() which may re-encode the buffer via
strbuf_reencode(), allocating new memory. The function then
immediately calls die() to exit, bypassing the cleanup code
at the end of the function that releases all allocated strbufs
and string_list resources.
This results in a memory leak detected by LeakSanitizer in the
re-encoded buffer allocated by reencode_string_iconv().
Fix this by releasing all allocated resources (refs_url, type,
charset, effective_url, buffer, protocol_header strbufs, and
extra_headers string_list) before calling die() in each error
case (HTTP_MISSING_TARGET, HTTP_NOAUTH, HTTP_NOMATCHPUBLICKEY,
HTTP_RATE_LIMITED, and the default case).
Signed-off-by: Vaidas Pilkauskas <[email protected]>1 parent 4c33b82 commit 5b859d1
1 file changed
+35
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
519 | 519 | | |
520 | 520 | | |
521 | 521 | | |
| 522 | + | |
| 523 | + | |
| 524 | + | |
| 525 | + | |
| 526 | + | |
| 527 | + | |
| 528 | + | |
522 | 529 | | |
523 | 530 | | |
524 | 531 | | |
525 | 532 | | |
| 533 | + | |
| 534 | + | |
| 535 | + | |
| 536 | + | |
| 537 | + | |
| 538 | + | |
| 539 | + | |
526 | 540 | | |
527 | 541 | | |
528 | 542 | | |
529 | 543 | | |
| 544 | + | |
| 545 | + | |
| 546 | + | |
| 547 | + | |
| 548 | + | |
| 549 | + | |
| 550 | + | |
530 | 551 | | |
531 | 552 | | |
532 | 553 | | |
533 | 554 | | |
| 555 | + | |
| 556 | + | |
| 557 | + | |
| 558 | + | |
| 559 | + | |
| 560 | + | |
| 561 | + | |
534 | 562 | | |
535 | 563 | | |
536 | 564 | | |
537 | 565 | | |
| 566 | + | |
| 567 | + | |
| 568 | + | |
| 569 | + | |
| 570 | + | |
| 571 | + | |
| 572 | + | |
538 | 573 | | |
539 | 574 | | |
540 | 575 | | |
| |||
0 commit comments