harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From regi...@apache.org
Subject svn commit: r980624 - in /harmony/enhanced/java/branches/java6/jdktools/modules/jpda/src/main/native/jdwp/common/agent: commands/ArrayReference.cpp commands/ArrayType.cpp commands/ObjectReference.cpp commands/ReferenceType.cpp core/PacketParser.cpp
Date Fri, 30 Jul 2010 01:04:05 GMT
Author: regisxu
Date: Fri Jul 30 01:04:05 2010
New Revision: 980624

URL: http://svn.apache.org/viewvc?rev=980624&view=rev
Log:
Check null after invoke InputPacketParser::ReadObjectID

Modified:
    harmony/enhanced/java/branches/java6/jdktools/modules/jpda/src/main/native/jdwp/common/agent/commands/ArrayReference.cpp
    harmony/enhanced/java/branches/java6/jdktools/modules/jpda/src/main/native/jdwp/common/agent/commands/ArrayType.cpp
    harmony/enhanced/java/branches/java6/jdktools/modules/jpda/src/main/native/jdwp/common/agent/commands/ObjectReference.cpp
    harmony/enhanced/java/branches/java6/jdktools/modules/jpda/src/main/native/jdwp/common/agent/commands/ReferenceType.cpp
    harmony/enhanced/java/branches/java6/jdktools/modules/jpda/src/main/native/jdwp/common/agent/core/PacketParser.cpp

Modified: harmony/enhanced/java/branches/java6/jdktools/modules/jpda/src/main/native/jdwp/common/agent/commands/ArrayReference.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/java/branches/java6/jdktools/modules/jpda/src/main/native/jdwp/common/agent/commands/ArrayReference.cpp?rev=980624&r1=980623&r2=980624&view=diff
==============================================================================
--- harmony/enhanced/java/branches/java6/jdktools/modules/jpda/src/main/native/jdwp/common/agent/commands/ArrayReference.cpp
(original)
+++ harmony/enhanced/java/branches/java6/jdktools/modules/jpda/src/main/native/jdwp/common/agent/commands/ArrayReference.cpp
Fri Jul 30 01:04:05 2010
@@ -30,12 +30,8 @@ int
 ArrayReference::LengthHandler::Execute(JNIEnv *jni) 
 {
     jarray arrayObject = (jarray)m_cmdParser->command.ReadArrayID(jni);
-    if (arrayObject == 0) {
-        JDWP_TRACE(LOG_RELEASE, (LOG_DATA_FL, "Length: null array: arrayID=%p", arrayObject));
-        AgentException e(JDWP_ERROR_INVALID_OBJECT);
-		JDWP_SET_EXCEPTION(e);
-        return JDWP_ERROR_INVALID_OBJECT;
-    }
+    JDWP_CHECK_NOT_NULL(arrayObject);
+
     jclass arrObjClass = jni->GetObjectClass(arrayObject);
 #ifndef NDEBUG 
     if (JDWP_TRACE_ENABLED(LOG_KIND_DATA)) {
@@ -310,13 +306,10 @@ ArrayReference::SetValuesHandler::Execut
     jint firstIndex = m_cmdParser->command.ReadInt();
     jint values = m_cmdParser->command.ReadInt();
 
+    JDWP_CHECK_NOT_NULL(arrayObject);
+
     JDWP_TRACE(LOG_RELEASE, (LOG_DATA_FL, "GetValues: received: arrayID=%p, firstIndex=%d,
values=%d", arrayObject, firstIndex, values));
 
-    if (arrayObject == 0) {
-        AgentException e(JDWP_ERROR_INVALID_OBJECT);
-		JDWP_SET_EXCEPTION(e);
-        return JDWP_ERROR_INVALID_OBJECT;
-    }
     if ((firstIndex < 0) || (values < 0)) {
         AgentException e(JDWP_ERROR_ILLEGAL_ARGUMENT);
 		JDWP_SET_EXCEPTION(e);

Modified: harmony/enhanced/java/branches/java6/jdktools/modules/jpda/src/main/native/jdwp/common/agent/commands/ArrayType.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/java/branches/java6/jdktools/modules/jpda/src/main/native/jdwp/common/agent/commands/ArrayType.cpp?rev=980624&r1=980623&r2=980624&view=diff
==============================================================================
--- harmony/enhanced/java/branches/java6/jdktools/modules/jpda/src/main/native/jdwp/common/agent/commands/ArrayType.cpp
(original)
+++ harmony/enhanced/java/branches/java6/jdktools/modules/jpda/src/main/native/jdwp/common/agent/commands/ArrayType.cpp
Fri Jul 30 01:04:05 2010
@@ -31,6 +31,7 @@ ArrayType::NewInstanceHandler::Execute(J
 {
     jclass cls = m_cmdParser->command.ReadReferenceTypeID(jni);
     jint length = m_cmdParser->command.ReadInt();
+    JDWP_CHECK_NOT_NULL(cls);
 
     JDWP_ASSERT(cls != 0);
     char* signature = 0;

Modified: harmony/enhanced/java/branches/java6/jdktools/modules/jpda/src/main/native/jdwp/common/agent/commands/ObjectReference.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/java/branches/java6/jdktools/modules/jpda/src/main/native/jdwp/common/agent/commands/ObjectReference.cpp?rev=980624&r1=980623&r2=980624&view=diff
==============================================================================
--- harmony/enhanced/java/branches/java6/jdktools/modules/jpda/src/main/native/jdwp/common/agent/commands/ObjectReference.cpp
(original)
+++ harmony/enhanced/java/branches/java6/jdktools/modules/jpda/src/main/native/jdwp/common/agent/commands/ObjectReference.cpp
Fri Jul 30 01:04:05 2010
@@ -35,13 +35,8 @@ ObjectReference::ReferenceTypeHandler::E
 {
     jobject jvmObject = m_cmdParser->command.ReadObjectID(jni);
     // Can be: InternalErrorException, OutOfMemoryException, JDWP_ERROR_INVALID_OBJECT
-    if (NULL == jvmObject) {
-        JDWP_TRACE(LOG_RELEASE, (LOG_DATA_FL, "ReferenceType: ReadObjectID() returned NULL"));
-        AgentException aex = GetExceptionManager().GetLastException();
-        jdwpError err = aex.ErrCode();
-        JDWP_SET_EXCEPTION(aex);
-        return err;
-    }
+    JDWP_CHECK_NOT_NULL(jvmObject);
+
     jclass jvmClass = jni->GetObjectClass(jvmObject); 
 
 #ifndef NDEBUG
@@ -50,7 +45,7 @@ ObjectReference::ReferenceTypeHandler::E
         char* signature = 0;
         JVMTI_TRACE(LOG_DEBUG, err, GetJvmtiEnv()->GetClassSignature(jvmClass, &signature,
0));
         JvmtiAutoFree afs(signature);
-        JDWP_TRACE(LOG_RELEASE, (LOG_DATA_FL, "ReferenceType: received: objectID=%p, classSignature=%s",
jvmObject, JDWP_CHECK_NULL(signature)));
+        JDWP_TRACE(LOG_RELEASE, (LOG_DATA_FL, "ObjectReference: received: objectID=%p, classSignature=%s",
jvmObject, JDWP_CHECK_NULL(signature)));
     }
 #endif
 
@@ -72,7 +67,7 @@ ObjectReference::ReferenceTypeHandler::E
 
     m_cmdParser->reply.WriteByte(refTypeTag);
     m_cmdParser->reply.WriteReferenceTypeID(jni, jvmClass);
-    JDWP_TRACE(LOG_RELEASE, (LOG_DATA_FL, "ReferenceType: send: refTypeTag=%d, refTypeID=%p",
refTypeTag, jvmClass));
+    JDWP_TRACE(LOG_RELEASE, (LOG_DATA_FL, "ObjectReference: send: refTypeTag=%d, refTypeID=%p",
refTypeTag, jvmClass));
 
     return JDWP_ERROR_NONE;
 } // ReferenceTypeHandler::Execute()
@@ -85,6 +80,8 @@ ObjectReference::GetValuesHandler::Execu
 {
     jdwpError jdwpErr;
     jobject jvmObject = m_cmdParser->command.ReadObjectID(jni);
+    JDWP_CHECK_NOT_NULL(jvmObject);
+
     // Can be: InternalErrorException, OutOfMemoryException, JDWP_ERROR_INVALID_OBJECT
     JDWP_CHECK_ERROR_CODE(jdwpErr);
 
@@ -521,6 +518,8 @@ ObjectReference::MonitorInfoHandler::Exe
     jobject jvmObject = m_cmdParser->command.ReadObjectID(jni);
     // Can be: InternalErrorException, OutOfMemoryException,
     // JDWP_ERROR_INVALID_OBJECT
+    JDWP_CHECK_NOT_NULL(jvmObject);
+
     JDWP_TRACE(LOG_RELEASE, (LOG_DATA_FL, "MonitorInfo: received: objectID=%p", jvmObject));
 
     jvmtiMonitorUsage monitorInfo;
@@ -649,8 +648,14 @@ int 
 ObjectReference::InvokeMethodHandler::Execute(JNIEnv *jni) 
 {
     m_object = m_cmdParser->command.ReadObjectID(jni);
+    JDWP_CHECK_NOT_NULL(m_object);
+
     m_thread = m_cmdParser->command.ReadThreadID(jni);
+    JDWP_CHECK_NOT_NULL(m_thread);
+
     m_clazz = m_cmdParser->command.ReadReferenceTypeID(jni);
+    JDWP_CHECK_NOT_NULL(m_clazz);
+
     m_methodID = m_cmdParser->command.ReadMethodID(jni);
     int arguments = m_cmdParser->command.ReadInt();
 
@@ -893,6 +898,7 @@ ObjectReference::ReferringObjectsHandler
     // Get objectID
     jobject jvmObject = m_cmdParser->command.ReadObjectID(jni);
     // Can be: InternalErrorException, OutOfMemoryException, JDWP_ERROR_INVALID_OBJECT
+    JDWP_CHECK_NOT_NULL(jvmObject);
 
     // Get maximum number of referring objects to return.
     int maxReferrers = m_cmdParser->command.ReadInt();

Modified: harmony/enhanced/java/branches/java6/jdktools/modules/jpda/src/main/native/jdwp/common/agent/commands/ReferenceType.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/java/branches/java6/jdktools/modules/jpda/src/main/native/jdwp/common/agent/commands/ReferenceType.cpp?rev=980624&r1=980623&r2=980624&view=diff
==============================================================================
--- harmony/enhanced/java/branches/java6/jdktools/modules/jpda/src/main/native/jdwp/common/agent/commands/ReferenceType.cpp
(original)
+++ harmony/enhanced/java/branches/java6/jdktools/modules/jpda/src/main/native/jdwp/common/agent/commands/ReferenceType.cpp
Fri Jul 30 01:04:05 2010
@@ -85,6 +85,9 @@ ReferenceType::ClassLoaderHandler::Execu
     jclass jvmClass = m_cmdParser->command.ReadReferenceTypeID(jni);
     // Can be: InternalErrorException, OutOfMemoryException,
     // JDWP_ERROR_INVALID_CLASS, JDWP_ERROR_INVALID_OBJECT
+    JDWP_CHECK_NOT_NULL(jvmClass);
+
+
 #ifndef NDEBUG
     if (JDWP_TRACE_ENABLED(LOG_KIND_DATA)) {
         jvmtiError err;
@@ -126,6 +129,8 @@ ReferenceType::ModifiersHandler::Execute
     jclass jvmClass = m_cmdParser->command.ReadReferenceTypeID(jni);
     // Can be: InternalErrorException, OutOfMemoryException,
     // JDWP_ERROR_INVALID_CLASS, JDWP_ERROR_INVALID_OBJECT
+    JDWP_CHECK_NOT_NULL(jvmClass);
+
 #ifndef NDEBUG
     if (JDWP_TRACE_ENABLED(LOG_KIND_DATA)) {
         jvmtiError err;
@@ -162,6 +167,8 @@ ReferenceType::FieldsHandler::Execute(JN
     jclass jvmClass = m_cmdParser->command.ReadReferenceTypeID(jni);
     // Can be: InternalErrorException, OutOfMemoryException,
     // JDWP_ERROR_INVALID_CLASS, JDWP_ERROR_INVALID_OBJECT
+    JDWP_CHECK_NOT_NULL(jvmClass);
+
 #ifndef NDEBUG
     if (JDWP_TRACE_ENABLED(LOG_KIND_DATA)) {
         jvmtiError err;
@@ -280,6 +287,8 @@ ReferenceType::MethodsHandler::Execute(J
     jclass jvmClass = m_cmdParser->command.ReadReferenceTypeID(jni);
     // Can be: InternalErrorException, OutOfMemoryException,
     // JDWP_ERROR_INVALID_CLASS, JDWP_ERROR_INVALID_OBJECT
+    JDWP_CHECK_NOT_NULL(jvmClass);
+
 #ifndef NDEBUG
     if (JDWP_TRACE_ENABLED(LOG_KIND_DATA)) {
         jvmtiError err;
@@ -393,6 +402,7 @@ ReferenceType::GetValuesHandler::Execute
     jclass jvmClass = m_cmdParser->command.ReadReferenceTypeID(jni);
     // Can be: InternalErrorException, OutOfMemoryException,
     // JDWP_ERROR_INVALID_CLASS, JDWP_ERROR_INVALID_OBJECT
+    JDWP_CHECK_NOT_NULL(jvmClass);
 
     jint fieldsNumber = m_cmdParser->command.ReadInt();
     // Can be: InternalErrorException
@@ -536,6 +546,8 @@ ReferenceType::SourceFileHandler::Execut
     jclass jvmClass = m_cmdParser->command.ReadReferenceTypeID(jni);
     // Can be: InternalErrorException, OutOfMemoryException,
     // JDWP_ERROR_INVALID_CLASS, JDWP_ERROR_INVALID_OBJECT
+    JDWP_CHECK_NOT_NULL(jvmClass);
+
 #ifndef NDEBUG
     if (JDWP_TRACE_ENABLED(LOG_KIND_DATA)) {
         jvmtiError err;
@@ -587,6 +599,8 @@ ReferenceType::NestedTypesHandler::Execu
     jclass jvmClass = m_cmdParser->command.ReadReferenceTypeID(jni);
     // Can be: InternalErrorException, OutOfMemoryException,
     // JDWP_ERROR_INVALID_CLASS, JDWP_ERROR_INVALID_OBJECT
+    JDWP_CHECK_NOT_NULL(jvmClass);
+
 #ifndef NDEBUG
     if (JDWP_TRACE_ENABLED(LOG_KIND_DATA)) {
         jvmtiError err;
@@ -738,6 +752,8 @@ ReferenceType::StatusHandler::Execute(JN
     jclass klass = m_cmdParser->command.ReadReferenceTypeID(jni);
     // Can be: InternalErrorException, OutOfMemoryException,
     // JDWP_ERROR_INVALID_CLASS, JDWP_ERROR_INVALID_OBJECT
+    JDWP_CHECK_NOT_NULL(klass);
+
 #ifndef NDEBUG
     if (JDWP_TRACE_ENABLED(LOG_KIND_DATA)) {
         jvmtiError err;
@@ -780,6 +796,8 @@ ReferenceType::InterfacesHandler::Execut
     jclass jvmClass = m_cmdParser->command.ReadReferenceTypeID(jni);
     // Can be: InternalErrorException, OutOfMemoryException,
     // JDWP_ERROR_INVALID_CLASS, JDWP_ERROR_INVALID_OBJECT
+    JDWP_CHECK_NOT_NULL(jvmClass);
+
 #ifndef NDEBUG
     if (JDWP_TRACE_ENABLED(LOG_KIND_DATA)) {
         jvmtiError err;
@@ -833,6 +851,8 @@ ReferenceType::ClassObjectHandler::Execu
     jclass jvmClass = m_cmdParser->command.ReadReferenceTypeID(jni);
     // Can be: InternalErrorException, OutOfMemoryException,
     // JDWP_ERROR_INVALID_CLASS, JDWP_ERROR_INVALID_OBJECT
+    JDWP_CHECK_NOT_NULL(jvmClass);
+
 #ifndef NDEBUG
     if (JDWP_TRACE_ENABLED(LOG_KIND_DATA)) {
         jvmtiError err;
@@ -857,6 +877,8 @@ ReferenceType::SourceDebugExtensionHandl
     jclass jvmClass = m_cmdParser->command.ReadReferenceTypeID(jni);
     // Can be: InternalErrorException, OutOfMemoryException,
     // JDWP_ERROR_INVALID_CLASS, JDWP_ERROR_INVALID_OBJECT
+    JDWP_CHECK_NOT_NULL(jvmClass);
+
 #ifndef NDEBUG
     if (JDWP_TRACE_ENABLED(LOG_KIND_DATA)) {
         jvmtiError err;
@@ -897,6 +919,8 @@ ReferenceType::InstancesHandler::Execute
     jclass jvmClass = m_cmdParser->command.ReadReferenceTypeID(jni);
     // Can be: InternalErrorException, OutOfMemoryException,
     // JDWP_ERROR_INVALID_CLASS, JDWP_ERROR_INVALID_OBJECT
+    JDWP_CHECK_NOT_NULL(jvmClass);
+
 #ifndef NDEBUG
     if (JDWP_TRACE_ENABLED(LOG_KIND_DATA)) {
         jvmtiError err;
@@ -1005,6 +1029,8 @@ ReferenceType::ClassFileVersionHandler::
      jclass jvmClass = m_cmdParser->command.ReadReferenceTypeID(jni);
     // Can be: InternalErrorException, OutOfMemoryException,
     // JDWP_ERROR_INVALID_CLASS, JDWP_ERROR_INVALID_OBJECT
+    JDWP_CHECK_NOT_NULL(jvmClass);
+
 #ifndef NDEBUG
     if (JDWP_TRACE_ENABLED(LOG_KIND_DATA)) {
         jvmtiError err;
@@ -1046,6 +1072,8 @@ ReferenceType::ConstantPoolHandler::Exec
     jclass jvmClass = m_cmdParser->command.ReadReferenceTypeID(jni);
     // Can be: InternalErrorException, OutOfMemoryException,
     // JDWP_ERROR_INVALID_CLASS, JDWP_ERROR_INVALID_OBJECT
+    JDWP_CHECK_NOT_NULL(jvmClass);
+
 #ifndef NDEBUG
     if (JDWP_TRACE_ENABLED(LOG_KIND_DATA)) {
         jvmtiError err;

Modified: harmony/enhanced/java/branches/java6/jdktools/modules/jpda/src/main/native/jdwp/common/agent/core/PacketParser.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/java/branches/java6/jdktools/modules/jpda/src/main/native/jdwp/common/agent/core/PacketParser.cpp?rev=980624&r1=980623&r2=980624&view=diff
==============================================================================
--- harmony/enhanced/java/branches/java6/jdktools/modules/jpda/src/main/native/jdwp/common/agent/core/PacketParser.cpp
(original)
+++ harmony/enhanced/java/branches/java6/jdktools/modules/jpda/src/main/native/jdwp/common/agent/core/PacketParser.cpp
Fri Jul 30 01:04:05 2010
@@ -255,6 +255,8 @@ jobject InputPacketParser::ReadObjectIDO
     // read raw ObjectID and check for null
     ObjectID oid = ReadRawObjectID();
     if (oid == 0) {
+        AgentException ex(JDWP_ERROR_INVALID_OBJECT);
+        JDWP_SET_EXCEPTION(ex);
         return 0;
     }
 
@@ -315,6 +317,12 @@ jclass InputPacketParser::ReadReferenceT
         // For a ObjectID, we should convert it to ReferenceTypeID 
         // if it is a ClassObjectID
         jobject obj = GetObjectManager().MapFromObjectID(jni, rtid);
+        if (NULL == obj) {
+            JDWP_TRACE(LOG_RELEASE, (LOG_DATA_FL, "MapFromObjectID returned NULL"));
+            AgentException ex(JDWP_ERROR_INVALID_OBJECT);
+            JDWP_SET_EXCEPTION(ex);
+            return 0;
+        }
         if (obj) {
           obj = jni->NewLocalRef(obj);
           if (!obj) {



Mime
View raw message