ObjFW  Check-in [416094d227]

Overview
Comment:OFFile: Fix closing fd 0 on failed init
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 416094d227446f1f41f4ab94416f4aeddd33a68f90f40cfa408f009c60447ce2
User & Date: js on 2023-10-08 11:36:53
Other Links: manifest | tags
Context
2023-10-08
11:44
Update ChangeLog check-in: 9b3a7b4fbb user: js tags: trunk
11:37
Add utils/ofhttpd check-in: 849f08ce02 user: js tags: ofhttpd
11:36
OFFile: Fix closing fd 0 on failed init check-in: 416094d227 user: js tags: trunk
11:36
Fix -[@"" stringByAppendingPathComponent:] check-in: 930f967649 user: js tags: trunk
Changes

Modified src/OFFile.h from [95a6d86e52] to [d53c4b0543].

35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
OF_SUBCLASSING_RESTRICTED
@interface OFFile: OFSeekableStream
#ifdef OF_FILE_HANDLE_IS_FD
    <OFReadyForReadingObserving, OFReadyForWritingObserving>
#endif
{
	OFFileHandle _handle;
	bool _atEndOfStream;
}

/**
 * @brief Creates a new OFFile with the specified path and mode.
 *
 * @param path The path to the file to open as a string
 * @param mode The mode in which the file should be opened.







|







35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
OF_SUBCLASSING_RESTRICTED
@interface OFFile: OFSeekableStream
#ifdef OF_FILE_HANDLE_IS_FD
    <OFReadyForReadingObserving, OFReadyForWritingObserving>
#endif
{
	OFFileHandle _handle;
	bool _initialized, _atEndOfStream;
}

/**
 * @brief Creates a new OFFile with the specified path and mode.
 *
 * @param path The path to the file to open as a string
 * @param mode The mode in which the file should be opened.

Modified src/OFFile.m from [11d5a8e0e1] to [df6d35b09d].

337
338
339
340
341
342
343

344
345
346
347
348
349
350
}

- (instancetype)initWithHandle: (OFFileHandle)handle
{
	self = [super init];

	_handle = handle;


	return self;
}

- (instancetype)init
{
	OF_INVALID_INIT_METHOD







>







337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
}

- (instancetype)initWithHandle: (OFFileHandle)handle
{
	self = [super init];

	_handle = handle;
	_initialized = true;

	return self;
}

- (instancetype)init
{
	OF_INVALID_INIT_METHOD
552
553
554
555
556
557
558
559
560
561
562
563
564
	_handle = OFInvalidFileHandle;

	[super close];
}

- (void)dealloc
{
	if (_handle != OFInvalidFileHandle)
		[self close];

	[super dealloc];
}
@end







|





553
554
555
556
557
558
559
560
561
562
563
564
565
	_handle = OFInvalidFileHandle;

	[super close];
}

- (void)dealloc
{
	if (_initialized && _handle != OFInvalidFileHandle)
		[self close];

	[super dealloc];
}
@end