Ticket #4125: 0001-Fix-4125-NULL-device-is-translated-to.patch

File 0001-Fix-4125-NULL-device-is-translated-to.patch, 1.6 KB (added by pdziepak, 8 years ago)
  • src/add-ons/kernel/file_systems/userlandfs/private/RequestAllocator.cpp

    From fbe63303b6ae052dff8376be06fa20593ba9ae2a Mon Sep 17 00:00:00 2001
    From: Pawel Dziepak <pdziepak@quarnos.org>
    Date: Sat, 7 Apr 2012 15:04:45 +0200
    Subject: [PATCH] Fix #4125: NULL device is translated to '//'
    
    The problem appeared to be on the request creating side (i.e. in the
    kernel add-on) which did not support NULL pointers properly.
    
    Relocation of addresses in request when it is received translates
    offset = 0, size = 0 to pointer NULL so that no change in that part
    of code was required.
    ---
     .../userlandfs/private/RequestAllocator.cpp        |   18 +++++++++++-------
     1 files changed, 11 insertions(+), 7 deletions(-)
    
    diff --git a/src/add-ons/kernel/file_systems/userlandfs/private/RequestAllocator.cpp b/src/add-ons/kernel/file_systems/userlandfs/private/RequestAllocator.cpp
    index 0316b56..8f33dbb 100644
    a b status_t  
    264264RequestAllocator::AllocateData(Address& address, const void* data, int32 size,
    265265    int32 align, bool deferredInit)
    266266{
    267     void* destination;
    268     status_t error = AllocateAddress(address, size, align, &destination,
    269         deferredInit);
    270     if (error != B_OK)
    271         return error;
    272     if (size > 0)
    273         memcpy(destination, data, size);
     267    status_t error = B_OK;
     268    if (data != NULL) {
     269        void* destination;
     270        error = AllocateAddress(address, size, align, &destination,
     271            deferredInit);
     272        if (error != B_OK)
     273            return error;
     274        if (size > 0)
     275            memcpy(destination, data, size);
     276    } else
     277        address.SetTo(-1, 0, 0);
    274278    return error;
    275279}
    276280