From 4e94fff19174acd0de0fa681d700e56799571999 Mon Sep 17 00:00:00 2001 From: "akhil.arora%sun.com" Date: Sat, 30 Oct 1999 02:14:28 +0000 Subject: [PATCH] r=akhil.arora@sun.com, fix by Denis Sharypov 13271: the wrong method was being called in ProcessingInstructionImpl.cpp 13338: handle null input arguments gracefully without crashing git-svn-id: svn://10.0.0.236/trunk@52307 18797224-902f-48f8-a5cc-f745e15eee43 --- .../java/dom/jni/org_mozilla_dom_AttrImpl.cpp | 13 +- .../jni/org_mozilla_dom_CharacterDataImpl.cpp | 52 +++++--- .../org_mozilla_dom_DOMImplementationImpl.cpp | 26 ++-- .../dom/jni/org_mozilla_dom_DocumentImpl.cpp | 117 +++++++++++------- .../dom/jni/org_mozilla_dom_ElementImpl.cpp | 69 +++++++---- .../java/dom/jni/org_mozilla_dom_NodeImpl.cpp | 106 ++++++++++------ ..._mozilla_dom_ProcessingInstructionImpl.cpp | 16 ++- 7 files changed, 246 insertions(+), 153 deletions(-) diff --git a/mozilla/java/dom/jni/org_mozilla_dom_AttrImpl.cpp b/mozilla/java/dom/jni/org_mozilla_dom_AttrImpl.cpp index d407b5f87b9..56e544bada9 100644 --- a/mozilla/java/dom/jni/org_mozilla_dom_AttrImpl.cpp +++ b/mozilla/java/dom/jni/org_mozilla_dom_AttrImpl.cpp @@ -128,12 +128,15 @@ JNIEXPORT void JNICALL Java_org_mozilla_dom_AttrImpl_setValue return; } + const char* cvalue = NULL; jboolean iscopy = JNI_FALSE; - const char* cvalue = env->GetStringUTFChars(jval, &iscopy); - if (!cvalue) { - PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR, - ("Attr.setValue: GetStringUTFChars failed\n")); - return; + if (jval) { + const char* cvalue = env->GetStringUTFChars(jval, &iscopy); + if (!cvalue) { + PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR, + ("Attr.setValue: GetStringUTFChars failed\n")); + return; + } } nsresult rv = attr->SetValue(cvalue); diff --git a/mozilla/java/dom/jni/org_mozilla_dom_CharacterDataImpl.cpp b/mozilla/java/dom/jni/org_mozilla_dom_CharacterDataImpl.cpp index 2ec6a07661d..b59dcfaf373 100644 --- a/mozilla/java/dom/jni/org_mozilla_dom_CharacterDataImpl.cpp +++ b/mozilla/java/dom/jni/org_mozilla_dom_CharacterDataImpl.cpp @@ -36,12 +36,15 @@ JNIEXPORT void JNICALL Java_org_mozilla_dom_CharacterDataImpl_appendData return; } + const char* value = NULL; jboolean iscopy = JNI_FALSE; - const char* value = env->GetStringUTFChars(jvalue, &iscopy); - if (!value) { - JavaDOMGlobals::ThrowException(env, - "CharacterData.appendData: GetStringUTFChars failed"); - return; + if (jvalue) { + value = env->GetStringUTFChars(jvalue, &iscopy); + if (!value) { + JavaDOMGlobals::ThrowException(env, + "CharacterData.appendData: GetStringUTFChars failed"); + return; + } } nsresult rv = data->AppendData(value); @@ -178,12 +181,15 @@ JNIEXPORT void JNICALL Java_org_mozilla_dom_CharacterDataImpl_insertData return; } + const char* value = NULL; jboolean iscopy = JNI_FALSE; - const char* value = env->GetStringUTFChars(jvalue, &iscopy); - if (!value) { - JavaDOMGlobals::ThrowException(env, - "CharacterData.insertData: GetStringUTFChars failed"); - return; + if (jvalue) { + value = env->GetStringUTFChars(jvalue, &iscopy); + if (!value) { + JavaDOMGlobals::ThrowException(env, + "CharacterData.insertData: GetStringUTFChars failed"); + return; + } } nsresult rv = data->InsertData((PRUint32) offset, value); @@ -226,12 +232,15 @@ JNIEXPORT void JNICALL Java_org_mozilla_dom_CharacterDataImpl_replaceData return; } + const char* value = NULL; jboolean iscopy = JNI_FALSE; - const char* value = env->GetStringUTFChars(jvalue, &iscopy); - if (!value) { - JavaDOMGlobals::ThrowException(env, - "CharacterData.replaceData: GetStringUTFChars failed"); - return; + if (jvalue) { + value = env->GetStringUTFChars(jvalue, &iscopy); + if (!value) { + JavaDOMGlobals::ThrowException(env, + "CharacterData.replaceData: GetStringUTFChars failed"); + return; + } } nsresult rv = data->ReplaceData((PRUint32) offset, (PRUint32) count, value); @@ -266,12 +275,15 @@ JNIEXPORT void JNICALL Java_org_mozilla_dom_CharacterDataImpl_setData return; } + const char* value = NULL; jboolean iscopy = JNI_FALSE; - const char* value = env->GetStringUTFChars(jvalue, &iscopy); - if (!value) { - JavaDOMGlobals::ThrowException(env, - "CharacterData.setData: GetStringUTFChars failed"); - return; + if (jvalue) { + value = env->GetStringUTFChars(jvalue, &iscopy); + if (!value) { + JavaDOMGlobals::ThrowException(env, + "CharacterData.setData: GetStringUTFChars failed"); + return; + } } nsresult rv = data->SetData(value); diff --git a/mozilla/java/dom/jni/org_mozilla_dom_DOMImplementationImpl.cpp b/mozilla/java/dom/jni/org_mozilla_dom_DOMImplementationImpl.cpp index 1c65fcdd4be..ee8d3cb94a3 100644 --- a/mozilla/java/dom/jni/org_mozilla_dom_DOMImplementationImpl.cpp +++ b/mozilla/java/dom/jni/org_mozilla_dom_DOMImplementationImpl.cpp @@ -143,20 +143,26 @@ JNIEXPORT jboolean JNICALL Java_org_mozilla_dom_DOMImplementationImpl_hasFeature return JNI_FALSE; } + const char* feature = NULL; jboolean iscopy = JNI_FALSE; - const char* feature = env->GetStringUTFChars(jfeature, &iscopy); - if (!feature) { - PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR, - ("DOMImplementation.hasFeature: GetStringUTFChars feature failed\n")); - return JNI_FALSE; + if (jfeature) { + feature = env->GetStringUTFChars(jfeature, &iscopy); + if (!feature) { + PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR, + ("DOMImplementation.hasFeature: GetStringUTFChars feature failed\n")); + return JNI_FALSE; + } } + const char* version = NULL; jboolean iscopy2 = JNI_FALSE; - const char* version = env->GetStringUTFChars(jversion, &iscopy2); - if (!version) { - PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR, - ("DOMImplementation.hasFeature: GetStringUTFChars version failed\n")); - return JNI_FALSE; + if (jversion) { + version = env->GetStringUTFChars(jversion, &iscopy2); + if (!version) { + PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR, + ("DOMImplementation.hasFeature: GetStringUTFChars version failed\n")); + return JNI_FALSE; + } } PRBool ret = PR_FALSE; diff --git a/mozilla/java/dom/jni/org_mozilla_dom_DocumentImpl.cpp b/mozilla/java/dom/jni/org_mozilla_dom_DocumentImpl.cpp index e69bb363dde..633a37ca7a0 100644 --- a/mozilla/java/dom/jni/org_mozilla_dom_DocumentImpl.cpp +++ b/mozilla/java/dom/jni/org_mozilla_dom_DocumentImpl.cpp @@ -61,13 +61,16 @@ JNIEXPORT jobject JNICALL Java_org_mozilla_dom_DocumentImpl_createAttribute return NULL; } + const char* name = NULL; nsIDOMAttr* ret = nsnull; jboolean iscopy = JNI_FALSE; - const char* name = env->GetStringUTFChars(jname, &iscopy); - if (!name) { - JavaDOMGlobals::ThrowException(env, - "Document.createAttribute: GetStringUTFChars failed"); - return NULL; + if (jname) { + name = env->GetStringUTFChars(jname, &iscopy); + if (!name) { + JavaDOMGlobals::ThrowException(env, + "Document.createAttribute: GetStringUTFChars failed"); + return NULL; + } } nsresult rv = doc->CreateAttribute(name, &ret); @@ -119,13 +122,16 @@ JNIEXPORT jobject JNICALL Java_org_mozilla_dom_DocumentImpl_createCDATASection return NULL; } + const char* data = NULL; nsIDOMCDATASection* ret = nsnull; jboolean iscopy = JNI_FALSE; - const char* data = env->GetStringUTFChars(jdata, &iscopy); - if (!data) { - JavaDOMGlobals::ThrowException(env, - "Document.createCDATASection: GetStringUTFChars failed"); - return NULL; + if (jdata) { + data = env->GetStringUTFChars(jdata, &iscopy); + if (!data) { + JavaDOMGlobals::ThrowException(env, + "Document.createCDATASection: GetStringUTFChars failed"); + return NULL; + } } nsresult rv = doc->CreateCDATASection(data, &ret); @@ -176,13 +182,16 @@ JNIEXPORT jobject JNICALL Java_org_mozilla_dom_DocumentImpl_createComment return NULL; } + const char* data = NULL; nsIDOMComment* ret = nsnull; jboolean iscopy = JNI_FALSE; - const char* data = env->GetStringUTFChars(jdata, &iscopy); - if (!data) { - JavaDOMGlobals::ThrowException(env, - "Document.createComment: GetStringUTFChars failed"); - return NULL; + if (jdata) { + data = env->GetStringUTFChars(jdata, &iscopy); + if (!data) { + JavaDOMGlobals::ThrowException(env, + "Document.createComment: GetStringUTFChars failed"); + return NULL; + } } nsresult rv = doc->CreateComment(data, &ret); @@ -270,13 +279,16 @@ JNIEXPORT jobject JNICALL Java_org_mozilla_dom_DocumentImpl_createElement return NULL; } + const char* tagName = NULL; nsIDOMElement* ret = nsnull; jboolean iscopy = JNI_FALSE; - const char* tagName = env->GetStringUTFChars(jtagName, &iscopy); - if (!tagName) { - JavaDOMGlobals::ThrowException(env, - "Document.createElement: GetStringUTFChars failed"); - return NULL; + if (jtagName) { + tagName = env->GetStringUTFChars(jtagName, &iscopy); + if (!tagName) { + JavaDOMGlobals::ThrowException(env, + "Document.createElement: GetStringUTFChars failed"); + return NULL; + } } nsresult rv = doc->CreateElement(tagName, &ret); @@ -328,13 +340,16 @@ JNIEXPORT jobject JNICALL Java_org_mozilla_dom_DocumentImpl_createEntityReferenc return NULL; } + const char* name = NULL; nsIDOMEntityReference* ret = nsnull; jboolean iscopy = JNI_FALSE; - const char* name = env->GetStringUTFChars(jname, &iscopy); - if (!name) { - JavaDOMGlobals::ThrowException(env, - "Document.createEntityReference: GetStringUTFChars failed"); - return NULL; + if (jname) { + name = env->GetStringUTFChars(jname, &iscopy); + if (!name) { + JavaDOMGlobals::ThrowException(env, + "Document.createEntityReference: GetStringUTFChars failed"); + return NULL; + } } nsresult rv = doc->CreateEntityReference(name, &ret); @@ -386,21 +401,27 @@ JNIEXPORT jobject JNICALL Java_org_mozilla_dom_DocumentImpl_createProcessingInst return NULL; } + const char* target = NULL; + const char* data = NULL; nsIDOMProcessingInstruction* ret = nsnull; jboolean iscopy = JNI_FALSE; jboolean iscopy2 = JNI_FALSE; - const char* target = env->GetStringUTFChars(jtarget, &iscopy); - if (!target) { - JavaDOMGlobals::ThrowException(env, - "Document.createProcessingInstruction: GetStringUTFChars target failed"); - return NULL; + if (jtarget) { + target = env->GetStringUTFChars(jtarget, &iscopy); + if (!target) { + JavaDOMGlobals::ThrowException(env, + "Document.createProcessingInstruction: GetStringUTFChars target failed"); + return NULL; + } } - const char* data = env->GetStringUTFChars(jdata, &iscopy2); - if (!data) { - JavaDOMGlobals::ThrowException(env, - "Document.createProcessingInstruction: GetStringUTFChars data failed"); - return NULL; + if (jdata) { + data = env->GetStringUTFChars(jdata, &iscopy2); + if (!data) { + JavaDOMGlobals::ThrowException(env, + "Document.createProcessingInstruction: GetStringUTFChars data failed"); + return NULL; + } } nsresult rv = doc->CreateProcessingInstruction(target, data, &ret); @@ -454,13 +475,16 @@ JNIEXPORT jobject JNICALL Java_org_mozilla_dom_DocumentImpl_createTextNode return NULL; } + const char* data = NULL; nsIDOMText* ret = nsnull; jboolean iscopy = JNI_FALSE; - const char* data = env->GetStringUTFChars(jdata, &iscopy); - if (!data) { - JavaDOMGlobals::ThrowException(env, - "Document.createAttribute: GetStringUTFChars failed"); - return NULL; + if (jdata) { + data = env->GetStringUTFChars(jdata, &iscopy); + if (!data) { + JavaDOMGlobals::ThrowException(env, + "Document.createAttribute: GetStringUTFChars failed"); + return NULL; + } } nsresult rv = doc->CreateTextNode(data, &ret); @@ -588,13 +612,16 @@ JNIEXPORT jobject JNICALL Java_org_mozilla_dom_DocumentImpl_getElementsByTagName return NULL; } + const char* tagName = NULL; nsIDOMNodeList* elements = nsnull; jboolean iscopy = JNI_FALSE; - const char* tagName = env->GetStringUTFChars(jtagName, &iscopy); - if (!tagName) { - JavaDOMGlobals::ThrowException(env, - "Document.getElementsByTagName: GetStringUTFChars failed"); - return NULL; + if (jtagName) { + tagName = env->GetStringUTFChars(jtagName, &iscopy); + if (!tagName) { + JavaDOMGlobals::ThrowException(env, + "Document.getElementsByTagName: GetStringUTFChars failed"); + return NULL; + } } nsresult rv = doc->GetElementsByTagName(tagName, &elements); diff --git a/mozilla/java/dom/jni/org_mozilla_dom_ElementImpl.cpp b/mozilla/java/dom/jni/org_mozilla_dom_ElementImpl.cpp index 17669699f9d..5b11c33d334 100644 --- a/mozilla/java/dom/jni/org_mozilla_dom_ElementImpl.cpp +++ b/mozilla/java/dom/jni/org_mozilla_dom_ElementImpl.cpp @@ -39,12 +39,15 @@ JNIEXPORT jstring JNICALL Java_org_mozilla_dom_ElementImpl_getAttribute return NULL; } + const char* cname = NULL; jboolean iscopy = JNI_FALSE; - const char* cname = env->GetStringUTFChars(jname, &iscopy); - if (!cname) { - JavaDOMGlobals::ThrowException(env, - "Element.getAttribute: GetStringUTFChars failed"); - return NULL; + if (jname) { + cname = env->GetStringUTFChars(jname, &iscopy); + if (!cname) { + JavaDOMGlobals::ThrowException(env, + "Element.getAttribute: GetStringUTFChars failed"); + return NULL; + } } nsString attr; @@ -83,23 +86,28 @@ JNIEXPORT jobject JNICALL Java_org_mozilla_dom_ElementImpl_getAttributeNode return NULL; } + const char* cname = NULL; jboolean iscopy = JNI_FALSE; - const char* cname = env->GetStringUTFChars(jname, &iscopy); - if (!cname) { - JavaDOMGlobals::ThrowException(env, - "Element.getAttributeNode: GetStringUTFChars failed"); - return NULL; + if (jname) { + cname = env->GetStringUTFChars(jname, &iscopy); + if (!cname) { + JavaDOMGlobals::ThrowException(env, + "Element.getAttributeNode: GetStringUTFChars failed"); + return NULL; + } } nsIDOMAttr* attr = nsnull; nsresult rv = element->GetAttributeNode(cname, &attr); if (iscopy == JNI_TRUE) env->ReleaseStringUTFChars(jname, cname); - if (NS_FAILED(rv) || !attr) { + if (NS_FAILED(rv)) { JavaDOMGlobals::ThrowException(env, "Element.getAttributeNode: failed", rv); return NULL; } + if (!attr) + return NULL; jobject jattr = env->AllocObject(JavaDOMGlobals::attrClass); if (!jattr) { @@ -135,12 +143,15 @@ JNIEXPORT jobject JNICALL Java_org_mozilla_dom_ElementImpl_getElementsByTagName return NULL; } + const char* cname = NULL; jboolean iscopy = JNI_FALSE; - const char* cname = env->GetStringUTFChars(jname, &iscopy); - if (!cname) { - JavaDOMGlobals::ThrowException(env, - "Element.getElementsByTagName: GetStringUTFChars failed"); - return NULL; + if (jname) { + cname = env->GetStringUTFChars(jname, &iscopy); + if (!cname) { + JavaDOMGlobals::ThrowException(env, + "Element.getElementsByTagName: GetStringUTFChars failed"); + return NULL; + } } nsIDOMNodeList* nodes = nsnull; @@ -340,20 +351,26 @@ JNIEXPORT void JNICALL Java_org_mozilla_dom_ElementImpl_setAttribute return; } + const char* name = NULL; + const char* value = NULL; jboolean iscopy = JNI_FALSE; - const char* name = env->GetStringUTFChars(jname, &iscopy); - if (!name) { - JavaDOMGlobals::ThrowException(env, - "Element.setAttribute: GetStringUTFChars name failed"); - return; + if (jname) { + name = env->GetStringUTFChars(jname, &iscopy); + if (!name) { + JavaDOMGlobals::ThrowException(env, + "Element.setAttribute: GetStringUTFChars name failed"); + return; + } } jboolean iscopy2 = JNI_FALSE; - const char* value = env->GetStringUTFChars(jvalue, &iscopy2); - if (!value) { - JavaDOMGlobals::ThrowException(env, - "Element.setAttribute: GetStringUTFChars name failed"); - return; + if (jvalue) { + value = env->GetStringUTFChars(jvalue, &iscopy2); + if (!value) { + JavaDOMGlobals::ThrowException(env, + "Element.setAttribute: GetStringUTFChars name failed"); + return; + } } nsresult rv = element->SetAttribute(name, value); diff --git a/mozilla/java/dom/jni/org_mozilla_dom_NodeImpl.cpp b/mozilla/java/dom/jni/org_mozilla_dom_NodeImpl.cpp index 3be114e9dee..31a903a7d09 100644 --- a/mozilla/java/dom/jni/org_mozilla_dom_NodeImpl.cpp +++ b/mozilla/java/dom/jni/org_mozilla_dom_NodeImpl.cpp @@ -34,6 +34,9 @@ JNIEXPORT jboolean JNICALL Java_org_mozilla_dom_NodeImpl_XPCOM_1equals { jboolean b_retFlag = JNI_FALSE; + if (!nodeArg) + return b_retFlag; + nsIDOMNode* p_thisNode = (nsIDOMNode*) env->GetLongField(jthis, JavaDOMGlobals::nodePtrFID); if (!p_thisNode) { @@ -138,12 +141,15 @@ JNIEXPORT jobject JNICALL Java_org_mozilla_dom_NodeImpl_appendChild return NULL; } - nsIDOMNode* child = (nsIDOMNode*) - env->GetLongField(jchild, JavaDOMGlobals::nodePtrFID); - if (!child) { - JavaDOMGlobals::ThrowException(env, - "Node.appendChild: NULL child pointer"); - return NULL; + nsIDOMNode* child = NULL; + if (jchild) { + child = (nsIDOMNode*) + env->GetLongField(jchild, JavaDOMGlobals::nodePtrFID); + if (!child) { + JavaDOMGlobals::ThrowException(env, + "Node.appendChild: NULL child pointer"); + return NULL; + } } nsIDOMNode* ret = nsnull; @@ -663,20 +669,26 @@ JNIEXPORT jobject JNICALL Java_org_mozilla_dom_NodeImpl_insertBefore return NULL; } - nsIDOMNode* newChild = (nsIDOMNode*) - env->GetLongField(jnewChild, JavaDOMGlobals::nodePtrFID); - if (!newChild) { - JavaDOMGlobals::ThrowException(env, - "Node.insertBefore: NULL newChild pointer"); - return NULL; + nsIDOMNode* newChild = NULL; + if (jnewChild) { + newChild = (nsIDOMNode*) + env->GetLongField(jnewChild, JavaDOMGlobals::nodePtrFID); + if (!newChild) { + JavaDOMGlobals::ThrowException(env, + "Node.insertBefore: NULL newChild pointer"); + return NULL; + } } - nsIDOMNode* refChild = (nsIDOMNode*) - env->GetLongField(jrefChild, JavaDOMGlobals::nodePtrFID); - if (!refChild) { - JavaDOMGlobals::ThrowException(env, - "Node.insertBefore: NULL refChild pointer"); - return NULL; + nsIDOMNode* refChild = NULL; + if (jrefChild) { + refChild = (nsIDOMNode*) + env->GetLongField(jrefChild, JavaDOMGlobals::nodePtrFID); + if (!refChild) { + JavaDOMGlobals::ThrowException(env, + "Node.insertBefore: NULL refChild pointer"); + return NULL; + } } nsIDOMNode* ret = nsnull; @@ -714,12 +726,15 @@ JNIEXPORT jobject JNICALL Java_org_mozilla_dom_NodeImpl_removeChild return NULL; } - nsIDOMNode* oldChild = (nsIDOMNode*) - env->GetLongField(joldChild, JavaDOMGlobals::nodePtrFID); - if (!oldChild) { - JavaDOMGlobals::ThrowException(env, - "Node.removeChild: NULL oldChild pointer"); - return NULL; + nsIDOMNode* oldChild = NULL; + if (joldChild) { + oldChild = (nsIDOMNode*) + env->GetLongField(joldChild, JavaDOMGlobals::nodePtrFID); + if (!oldChild) { + JavaDOMGlobals::ThrowException(env, + "Node.removeChild: NULL oldChild pointer"); + return NULL; + } } nsIDOMNode* ret = nsnull; @@ -755,20 +770,26 @@ JNIEXPORT jobject JNICALL Java_org_mozilla_dom_NodeImpl_replaceChild return NULL; } - nsIDOMNode* newChild = (nsIDOMNode*) - env->GetLongField(jnewChild, JavaDOMGlobals::nodePtrFID); - if (!newChild) { - JavaDOMGlobals::ThrowException(env, - "Node.replaceChild: NULL newChild pointer"); - return NULL; + nsIDOMNode* newChild = NULL; + if (jnewChild) { + newChild = (nsIDOMNode*) + env->GetLongField(jnewChild, JavaDOMGlobals::nodePtrFID); + if (!newChild) { + JavaDOMGlobals::ThrowException(env, + "Node.replaceChild: NULL newChild pointer"); + return NULL; + } } - nsIDOMNode* oldChild = (nsIDOMNode*) - env->GetLongField(joldChild, JavaDOMGlobals::nodePtrFID); - if (!oldChild) { - JavaDOMGlobals::ThrowException(env, - "Node.replaceChild: NULL oldChild pointer"); - return NULL; + nsIDOMNode* oldChild = NULL; + if (joldChild) { + oldChild = (nsIDOMNode*) + env->GetLongField(joldChild, JavaDOMGlobals::nodePtrFID); + if (!oldChild) { + JavaDOMGlobals::ThrowException(env, + "Node.replaceChild: NULL oldChild pointer"); + return NULL; + } } nsIDOMNode* ret = nsnull; @@ -806,12 +827,15 @@ JNIEXPORT void JNICALL Java_org_mozilla_dom_NodeImpl_setNodeValue return; } + const char* value = NULL; jboolean iscopy = JNI_FALSE; - const char* value = env->GetStringUTFChars(jvalue, &iscopy); - if (!value) { - JavaDOMGlobals::ThrowException(env, - "Node.setNodeValue: GetStringUTFChars failed"); - return; + if (jvalue) { + value = env->GetStringUTFChars(jvalue, &iscopy); + if (!value) { + JavaDOMGlobals::ThrowException(env, + "Node.setNodeValue: GetStringUTFChars failed"); + return; + } } nsresult rv = node->SetNodeValue(value); diff --git a/mozilla/java/dom/jni/org_mozilla_dom_ProcessingInstructionImpl.cpp b/mozilla/java/dom/jni/org_mozilla_dom_ProcessingInstructionImpl.cpp index bfb9e85461f..8f4f09323ca 100644 --- a/mozilla/java/dom/jni/org_mozilla_dom_ProcessingInstructionImpl.cpp +++ b/mozilla/java/dom/jni/org_mozilla_dom_ProcessingInstructionImpl.cpp @@ -72,7 +72,7 @@ JNIEXPORT jstring JNICALL Java_org_mozilla_dom_ProcessingInstructionImpl_getTarg } nsString ret; - nsresult rv = pi->GetData(ret); + nsresult rv = pi->GetTarget(ret); if (NS_FAILED(rv)) { JavaDOMGlobals::ThrowException(env, "ProcessingInstruction.getTarget: failed", rv); @@ -105,13 +105,17 @@ JNIEXPORT void JNICALL Java_org_mozilla_dom_ProcessingInstructionImpl_setData return; } + const char* data = NULL; jboolean iscopy = JNI_FALSE; - const char* data = env->GetStringUTFChars(jdata, &iscopy); - if (!data) { - JavaDOMGlobals::ThrowException(env, - "ProcessingInstruction.setData: GetStringUTFChars failed"); - return; + if (jdata) { + data = env->GetStringUTFChars(jdata, &iscopy); + if (!data) { + JavaDOMGlobals::ThrowException(env, + "ProcessingInstruction.setData: GetStringUTFChars failed"); + return; + } } + nsresult rv = pi->SetData(data); if (iscopy == JNI_TRUE) env->ReleaseStringUTFChars(jdata, data);