Page MenuHomeFreeBSD

Fix CID 977702 (Resource leak) in ed io.c
ClosedPublic

Authored by truckman on May 25 2016, 4:37 AM.
Tags
None
Referenced Files
Unknown Object (File)
Mon, Dec 2, 4:37 PM
Unknown Object (File)
Mon, Dec 2, 4:37 PM
Unknown Object (File)
Mon, Dec 2, 4:37 PM
Unknown Object (File)
Mon, Dec 2, 4:37 PM
Unknown Object (File)
Mon, Dec 2, 12:49 AM
Unknown Object (File)
Sat, Nov 30, 3:03 AM
Unknown Object (File)
Mon, Nov 25, 9:56 PM
Unknown Object (File)
Sun, Nov 24, 10:55 PM
Subscribers

Details

Summary

Close the input FILE * in read_file() and the output FILE *
in write_file() if read_stream() or write_stream() fails.

Test Plan

Test reads and writes of both plain files and to/from commands.

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

truckman retitled this revision from to Fix CID 977702 (Resource leak) in ed io.c.
truckman updated this object.
truckman edited the test plan for this revision. (Show Details)
truckman added a reviewer: pfg.
pfg edited edge metadata.

Looks good to me.

bin/ed/io.c
56 ↗(On Diff #16840)

We can get rid of the brackets since it's only one statement. (Same thing in write_file)

This revision is now accepted and ready to land.May 25 2016, 3:01 PM
bin/ed/io.c
56 ↗(On Diff #16840)

There was a recent style(9) discussion about this and style(9) was updated to permit this. The consensus was that using the brackets is preferred in new code because it is less error prone and there is less repo churn if another statement is added. However, doing a sweep to add brackets to existing code is not permitted.

bin/ed/io.c
56 ↗(On Diff #16840)

I am aware of the style(9) discussion (I voted against it).
I am not objecting as the revision was accepted but the existing code in ed(1) uses the non-bracket style for single line declarations and I think we should preserve it.

truckman edited edge metadata.
truckman edited the test plan for this revision. (Show Details)

Match existing {} style

This revision now requires review to proceed.May 25 2016, 6:01 PM
pfg edited edge metadata.
This revision is now accepted and ready to land.May 25 2016, 6:33 PM
This revision was automatically updated to reflect the committed changes.