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
F103121507: D6554.id16840.diff
Thu, Nov 21, 7:15 AM
F103121075: D6554.id.diff
Thu, Nov 21, 7:08 AM
Unknown Object (File)
Wed, Nov 20, 12:53 PM
Unknown Object (File)
Wed, Nov 20, 9:18 AM
Unknown Object (File)
Wed, Nov 20, 9:12 AM
Unknown Object (File)
Tue, Nov 19, 7:20 AM
Unknown Object (File)
Sat, Nov 9, 2:57 PM
Unknown Object (File)
Fri, Nov 8, 5:37 AM
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.