#vulnerable code 
                                @Override
    public long getSwapUsed() {
        long total;
        long available;
        
        if (!Kernel32.INSTANCE.GlobalMemoryStatusEx(this._memory)) {
            LOG.error("Failed to Initialize MemoryStatusEx. Error code: {}", Kernel32.INSTANCE.GetLastError());
            this._memory = null;
            return 0L;
        }

        total = this.getSwapTotal();
        available = this._memory.ullAvailPageFile.longValue() - this._memory.ullAvailPhys.longValue();
        
        return total - available;
    } 
                            #location 12 
                            #vulnerability type NULL_DEREFERENCE
#fixed code
                                @Override
    public long getSwapUsed() {
        PdhFmtCounterValue phPagefileCounterValue = new PdhFmtCounterValue();
        int ret = Pdh.INSTANCE.PdhGetFormattedCounterValue(pPagefile.getValue(), Pdh.PDH_FMT_LARGE | Pdh.PDH_FMT_1000,
                null, phPagefileCounterValue);
        if (ret != 0) {
            LOG.warn("Failed to get Pagefile % Usage counter. Error code: {}", String.format("0x%08X", ret));
            return 0L;
        }
        // Returns results in 1000's of percent, e.g. 5% is 5000
        // Multiply by page file size and Divide by 100 * 1000
        // Putting division at end avoids need to cast division to double
        return getSwapTotal() * phPagefileCounterValue.value.largeValue / 100000;
    }