Tried adding else to close file to prevent file descriptor leak #2528

pull tariq786 wants to merge 3 commits into bitcoin:master from tariq786:my-new-branch changing 1 files +2 −0
  1. tariq786 commented at 6:57 PM on April 14, 2013: none

    No description provided.

  2. Tried adding else to close file to prevent file descriptor leak 199a8af659
  3. added else if with NULL condition check 479aeb697c
  4. Fixed indentation in else if d0307c46f4
  5. in src/util.cpp:None in 199a8af659 outdated
    1230 | @@ -1231,6 +1231,8 @@ void ShrinkDebugFile()
    1231 |              fclose(file);
    1232 |          }
    1233 |      }
    1234 | +    else
    1235 | +	fclose(file);
    


    laanwj commented at 7:05 PM on April 14, 2013:

    This fix is not correct. It indeed looks like there is currently a fd leak when file && GetFilesize(file) < 10 * 1000000, but your change would also cause a fclose in the case that file == NULL (when the debug log cannot be opened; resulting in a segmentation fault).

  6. in src/util.cpp:None in 479aeb697c outdated
    1230 | @@ -1231,6 +1231,8 @@ void ShrinkDebugFile()
    1231 |              fclose(file);
    1232 |          }
    1233 |      }
    1234 | +    else if(file != NULL)
    


    Diapolo commented at 7:19 PM on April 14, 2013:

    IMHO it would be sufficient to write: else if (file)

    And please also check your indentation below!


    tariq786 commented at 7:24 PM on April 14, 2013:

    i have done the same (IMHO) and fixed the indentation issue as well

  7. laanwj commented at 7:42 PM on April 14, 2013: member

    ACK

  8. Diapolo commented at 8:26 PM on April 14, 2013: none

    You need to squash the 2 commits into one and I still see the indentation issue?

  9. sipa commented at 10:19 PM on April 15, 2013: member

    ACK, if you squash the commits together.

  10. BitcoinPullTester commented at 1:06 AM on April 16, 2013: none

    Automatic sanity-testing: PASSED, see http://jenkins.bluematt.me/pull-tester/d0307c46f4013f7d60e505e3a1c737ebd6788203 for binaries and test log. This test script verifies pulls every time they are updated. It, however, dies sometimes and fails to test properly. If you are waiting on a test, please check timestamps to verify that the test.log is moving at http://jenkins.bluematt.me/pull-tester/current/ Contact BlueMatt on freenode if something looks broken.

  11. laanwj commented at 2:02 PM on April 27, 2013: member

    See #2584

  12. laanwj closed this on Apr 27, 2013

  13. DrahtBot locked this on Sep 8, 2021

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-04-13 18:16 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me