#vulnerable code 
                                @Override
    public int[] getFanSpeeds() {
        int[] fanSpeeds = new int[1];
        ArrayList<String> hwInfo = ExecutingCommand
                .runNative("wmic /namespace:\\\\root\\cimv2 PATH Win32_Fan get DesiredSpeed");
        for (String checkLine : hwInfo) {
            if (checkLine.length() == 0 || checkLine.toLowerCase().contains("desiredspeed")) {
                continue;
            } else {
                // If successful
                try {
                    int rpm = Integer.parseInt(checkLine.trim());
                    // Check if 8th bit (of 16 bit number) is set
                    if (rpm > 0) {
                        fanSpeeds[0] = rpm;
                        return fanSpeeds;
                    }
                } catch (NumberFormatException e) {
                    // If we failed to parse, give up
                }
                break;
            }
        }
        return fanSpeeds;
    } 
                            #location 6 
                            #vulnerability type NULL_DEREFERENCE
#fixed code
                                @Override
    public int[] getFanSpeeds() {
        // Initialize
        int[] fanSpeeds = new int[1];
        // If we couldn't get through normal WMI go directly to OHM
        if (!this.fanSpeedWMI) {
            double[] vals = wmiGetValuesForKeys("/namespace:\\\\root\\OpenHardwareMonitor PATH Sensor", null, "Fan",
                    "Parent,SensorType,Value");
            if (vals.length > 0) {
                fanSpeeds = new int[vals.length];
                for (int i = 0; i < vals.length; i++) {
                    fanSpeeds[i] = (int) vals[i];
                }
            }
            return fanSpeeds;
        }
        // This branch is used the first time and all subsequent times if
        // successful (fanSpeedWMI == true)
        // Try to get value
        int rpm = wmiGetValue("/namespace:\\\\root\\cimv2 PATH Win32_Fan", "DesiredSpeed");
        // Set in array and return
        if (rpm > 0) {
            fanSpeeds[0] = rpm;
        } else {
            // Fail, switch to OHM
            this.fanSpeedWMI = false;
            return getFanSpeeds();
        }
        return fanSpeeds;
    }