Skip to content

Commit acd34c5

Browse files
authored
Merge pull request #1573 from nicolasnoble/file-null-fix
Fixing nullchecks on the File object.
2 parents 2324886 + 5197311 commit acd34c5

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

src/core/sio1.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ void PCSX::SIO1::interrupt() {
144144

145145
uint8_t PCSX::SIO1::readData8() {
146146
updateStat();
147-
if (m_sio1fifo || !m_sio1fifo->eof()) {
147+
if (m_sio1fifo && !m_sio1fifo->eof()) {
148148
if (m_regs.status & SR_RXRDY) {
149149
m_regs.data = m_sio1fifo->byte();
150150
g_emulator->m_mem->writeHardwareRegister<0x1050, uint8_t>(m_regs.data);
@@ -156,7 +156,7 @@ uint8_t PCSX::SIO1::readData8() {
156156

157157
uint16_t PCSX::SIO1::readData16() {
158158
updateStat();
159-
if (m_sio1fifo || !m_sio1fifo->eof()) {
159+
if (m_sio1fifo && !m_sio1fifo->eof()) {
160160
if (m_regs.status & SR_RXRDY) {
161161
m_sio1fifo->read(&m_regs.data, 2);
162162
g_emulator->m_mem->writeHardwareRegister<0x1050, uint16_t>(m_regs.data);
@@ -168,7 +168,7 @@ uint16_t PCSX::SIO1::readData16() {
168168

169169
uint32_t PCSX::SIO1::readData32() {
170170
updateStat();
171-
if (m_sio1fifo || !m_sio1fifo->eof()) {
171+
if (m_sio1fifo && !m_sio1fifo->eof()) {
172172
if (m_regs.status & SR_RXRDY) {
173173
m_sio1fifo->read(&m_regs.data, 4);
174174
g_emulator->m_mem->writeHardwareRegister<0x1050, uint32_t>(m_regs.data);

src/support/file.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -326,7 +326,8 @@ class IO : public IOBase {
326326
if (!r) throw std::runtime_error("operator-> used with incompatible type - shouldn't happen");
327327
return r;
328328
}
329-
bool isNull() { return dynamic_cast<T*>(m_file); }
329+
bool isNull() const { return !dynamic_cast<T*>(m_file); }
330+
operator bool() const { return !isNull(); }
330331
};
331332

332333
class FailedFile : public File {

0 commit comments

Comments
 (0)