kernel/eka/drivers/usbho/usbdescriptors/usbdescparser.cpp
branchRCL_3
changeset 43 c1f20ce4abcf
parent 23 1df514389a47
child 44 3e88ff8f41d5
--- a/kernel/eka/drivers/usbho/usbdescriptors/usbdescparser.cpp	Thu Aug 19 11:14:22 2010 +0300
+++ b/kernel/eka/drivers/usbho/usbdescriptors/usbdescparser.cpp	Tue Aug 31 16:34:26 2010 +0300
@@ -49,16 +49,18 @@
 
 	// First we must find the top level descriptor (the one we will return to the caller).
 	TRAP(ret, aDesc = FindParserAndParseAndCheckL(des, NULL));
-	if(ret == KErrNone && !aDesc)
-		{
-		ret = KErrNotFound;
-		}
-
 	if(ret == KErrNone)
 		{
-		// Now we have a top level descriptor - we now try to build up the descriptor
-		// tree if there are more descriptors available.
-		TRAP(ret, ParseDescriptorTreeL(des, *aDesc));
+		if(!aDesc)
+			{
+			ret = KErrNotFound;
+			}
+		else
+			{
+			// Now we have a top level descriptor - we now try to build up the descriptor
+			// tree if there are more descriptors available.
+			TRAP(ret, ParseDescriptorTreeL(des, *aDesc));
+			}
 		}
 
 	// Ensure that all the data has been parsed if successful.
@@ -69,6 +71,13 @@
 		ret = KErrUnknown;
 		}
 
+	// release the allocated descriptor if there was an error
+	if(ret != KErrNone && aDesc)
+		{
+		delete aDesc;
+		aDesc = NULL;
+		}
+
 	return ret;
 	}