Ticket #11716: 0001-NetFSServer-Forward-errors-and-fix-use-after-free.patch

File 0001-NetFSServer-Forward-errors-and-fix-use-after-free.patch, 1.2 KB (added by Timothy_Gu, 7 years ago)

Use B_NO_MEMORY

  • src/add-ons/kernel/file_systems/netfs/server/NetFSServer.cpp

    From eec943d958efce825cb57e33b7006fa8b243a139 Mon Sep 17 00:00:00 2001
    From: Timothy Gu <timothygu99@gmail.com>
    Date: Tue, 6 Jan 2015 16:11:58 -0800
    Subject: [PATCH] NetFSServer: Forward errors and fix use-after-free
    
    Fix CID 1255311.
    
    At least right now, the constructor of ServerInfoSender can only fail because
    of OOM.
    ---
     src/add-ons/kernel/file_systems/netfs/server/NetFSServer.cpp | 8 +++++++-
     1 file changed, 7 insertions(+), 1 deletion(-)
    
    diff --git a/src/add-ons/kernel/file_systems/netfs/server/NetFSServer.cpp b/src/add-ons/kernel/file_systems/netfs/server/NetFSServer.cpp
    index 49041d1..b274b90 100644
    a b NetFSServer::_ServerInfoConnectionListener()  
    12831283
    12841284        // create a server info sender thread
    12851285        ServerInfoSender* sender = new(std::nothrow) ServerInfoSender(fd, info);
    1286         if (!sender || sender->Init() != B_OK) {
     1286        if (!sender) {
    12871287            closesocket(fd);
    12881288            delete sender;
     1289            return B_NO_MEMORY;
     1290        }
     1291        if ((error = sender->Init()) != B_OK) {
     1292            closesocket(fd);
     1293            delete sender;
     1294            return error;
    12891295        }
    12901296        taskManager.RunTask(sender);
    12911297    }