fixed potential Obd2Amb bug 26/2526/1
authorKevron Rees <tripzero.kev@gmail.com>
Tue, 27 Nov 2012 01:55:13 +0000 (17:55 -0800)
committerKevron Rees <tripzero.kev@gmail.com>
Tue, 27 Nov 2012 01:55:13 +0000 (17:55 -0800)
plugins/obd2plugin/obd2source.cpp
plugins/obd2plugin/obd2source.h
plugins/obd2plugin/obdpid.h

index 9fd7631..ddd439c 100644 (file)
@@ -727,6 +727,11 @@ void OBD2Source::subscribeToPropertyChanges(VehicleProperty::Property property)
 
 
                ObdPid *pid = obd2AmbInstance->createPidforProperty(property);
+
+               if(!pid)
+               {
+                       return;
+               }
                
                //If the pid is currently in the blacklist map, erase it. This allows for applications
                //to "un-blacklist" a pid by re-subscribing to it.
index 0182edc..60045de 100644 (file)
@@ -79,6 +79,15 @@ public:
                supportedPidsList.push_back(new EngineCoolantPid());
                supportedPidsList.push_back(new AirIntakeTemperaturePid());
        }
+
+       ~Obd2Amb()
+       {
+               for(auto itr = supportedPidsList.begin(); itr != supportedPidsList.end(); itr++)
+               {
+                       delete *itr;
+               }
+       }
+
        ObdPid* createPidFromReply(ByteArray replyVector)
        {
                for(auto itr = supportedPidsList.begin(); itr != supportedPidsList.end(); itr++)
@@ -98,12 +107,14 @@ public:
        {
                for(auto itr = supportedPidsList.begin(); itr != supportedPidsList.end(); itr++)
                {
-                       if((*itr)->property == property)
+                       VehicleProperty::Property p = (*itr)->property;
+                       if(p == property)
                        {
                                ObdPid* obj = *itr;
                                return obj->create();
                        }
                }
+               return NULL;
        }
 
        std::list<ObdPid*> supportedPidsList;
index 3823317..a8b3965 100644 (file)
@@ -129,7 +129,7 @@ public:
        bool tryParse(ByteArray replyVector)
        {
                ByteArray tmp = compress(cleanup(replyVector));
-               if (tmp[1] != 0x05)
+               if (tmp[1] != id)
                {
                        return false;
                }