13271: the wrong method was being called in ProcessingInstructionImpl.cpp
13338: handle null input arguments gracefully without crashing
This commit is contained in:
akhil.arora%sun.com 1999-10-30 02:14:28 +00:00
Родитель 7407ea381a
Коммит 66c3fae066
7 изменённых файлов: 246 добавлений и 153 удалений

Просмотреть файл

@ -128,13 +128,16 @@ JNIEXPORT void JNICALL Java_org_mozilla_dom_AttrImpl_setValue
return; return;
} }
const char* cvalue = NULL;
jboolean iscopy = JNI_FALSE; jboolean iscopy = JNI_FALSE;
if (jval) {
const char* cvalue = env->GetStringUTFChars(jval, &iscopy); const char* cvalue = env->GetStringUTFChars(jval, &iscopy);
if (!cvalue) { if (!cvalue) {
PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR, PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR,
("Attr.setValue: GetStringUTFChars failed\n")); ("Attr.setValue: GetStringUTFChars failed\n"));
return; return;
} }
}
nsresult rv = attr->SetValue(cvalue); nsresult rv = attr->SetValue(cvalue);
if (iscopy == JNI_TRUE) if (iscopy == JNI_TRUE)

Просмотреть файл

@ -36,13 +36,16 @@ JNIEXPORT void JNICALL Java_org_mozilla_dom_CharacterDataImpl_appendData
return; return;
} }
const char* value = NULL;
jboolean iscopy = JNI_FALSE; jboolean iscopy = JNI_FALSE;
const char* value = env->GetStringUTFChars(jvalue, &iscopy); if (jvalue) {
value = env->GetStringUTFChars(jvalue, &iscopy);
if (!value) { if (!value) {
JavaDOMGlobals::ThrowException(env, JavaDOMGlobals::ThrowException(env,
"CharacterData.appendData: GetStringUTFChars failed"); "CharacterData.appendData: GetStringUTFChars failed");
return; return;
} }
}
nsresult rv = data->AppendData(value); nsresult rv = data->AppendData(value);
if (iscopy == JNI_TRUE) if (iscopy == JNI_TRUE)
@ -178,13 +181,16 @@ JNIEXPORT void JNICALL Java_org_mozilla_dom_CharacterDataImpl_insertData
return; return;
} }
const char* value = NULL;
jboolean iscopy = JNI_FALSE; jboolean iscopy = JNI_FALSE;
const char* value = env->GetStringUTFChars(jvalue, &iscopy); if (jvalue) {
value = env->GetStringUTFChars(jvalue, &iscopy);
if (!value) { if (!value) {
JavaDOMGlobals::ThrowException(env, JavaDOMGlobals::ThrowException(env,
"CharacterData.insertData: GetStringUTFChars failed"); "CharacterData.insertData: GetStringUTFChars failed");
return; return;
} }
}
nsresult rv = data->InsertData((PRUint32) offset, value); nsresult rv = data->InsertData((PRUint32) offset, value);
if (iscopy == JNI_TRUE) if (iscopy == JNI_TRUE)
@ -226,13 +232,16 @@ JNIEXPORT void JNICALL Java_org_mozilla_dom_CharacterDataImpl_replaceData
return; return;
} }
const char* value = NULL;
jboolean iscopy = JNI_FALSE; jboolean iscopy = JNI_FALSE;
const char* value = env->GetStringUTFChars(jvalue, &iscopy); if (jvalue) {
value = env->GetStringUTFChars(jvalue, &iscopy);
if (!value) { if (!value) {
JavaDOMGlobals::ThrowException(env, JavaDOMGlobals::ThrowException(env,
"CharacterData.replaceData: GetStringUTFChars failed"); "CharacterData.replaceData: GetStringUTFChars failed");
return; return;
} }
}
nsresult rv = data->ReplaceData((PRUint32) offset, (PRUint32) count, value); nsresult rv = data->ReplaceData((PRUint32) offset, (PRUint32) count, value);
if (iscopy == JNI_TRUE) if (iscopy == JNI_TRUE)
@ -266,13 +275,16 @@ JNIEXPORT void JNICALL Java_org_mozilla_dom_CharacterDataImpl_setData
return; return;
} }
const char* value = NULL;
jboolean iscopy = JNI_FALSE; jboolean iscopy = JNI_FALSE;
const char* value = env->GetStringUTFChars(jvalue, &iscopy); if (jvalue) {
value = env->GetStringUTFChars(jvalue, &iscopy);
if (!value) { if (!value) {
JavaDOMGlobals::ThrowException(env, JavaDOMGlobals::ThrowException(env,
"CharacterData.setData: GetStringUTFChars failed"); "CharacterData.setData: GetStringUTFChars failed");
return; return;
} }
}
nsresult rv = data->SetData(value); nsresult rv = data->SetData(value);
if (iscopy == JNI_TRUE) if (iscopy == JNI_TRUE)

Просмотреть файл

@ -143,21 +143,27 @@ JNIEXPORT jboolean JNICALL Java_org_mozilla_dom_DOMImplementationImpl_hasFeature
return JNI_FALSE; return JNI_FALSE;
} }
const char* feature = NULL;
jboolean iscopy = JNI_FALSE; jboolean iscopy = JNI_FALSE;
const char* feature = env->GetStringUTFChars(jfeature, &iscopy); if (jfeature) {
feature = env->GetStringUTFChars(jfeature, &iscopy);
if (!feature) { if (!feature) {
PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR, PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR,
("DOMImplementation.hasFeature: GetStringUTFChars feature failed\n")); ("DOMImplementation.hasFeature: GetStringUTFChars feature failed\n"));
return JNI_FALSE; return JNI_FALSE;
} }
}
const char* version = NULL;
jboolean iscopy2 = JNI_FALSE; jboolean iscopy2 = JNI_FALSE;
const char* version = env->GetStringUTFChars(jversion, &iscopy2); if (jversion) {
version = env->GetStringUTFChars(jversion, &iscopy2);
if (!version) { if (!version) {
PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR, PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR,
("DOMImplementation.hasFeature: GetStringUTFChars version failed\n")); ("DOMImplementation.hasFeature: GetStringUTFChars version failed\n"));
return JNI_FALSE; return JNI_FALSE;
} }
}
PRBool ret = PR_FALSE; PRBool ret = PR_FALSE;
nsresult rv = dom->HasFeature(feature, version, &ret); nsresult rv = dom->HasFeature(feature, version, &ret);

Просмотреть файл

@ -61,14 +61,17 @@ JNIEXPORT jobject JNICALL Java_org_mozilla_dom_DocumentImpl_createAttribute
return NULL; return NULL;
} }
const char* name = NULL;
nsIDOMAttr* ret = nsnull; nsIDOMAttr* ret = nsnull;
jboolean iscopy = JNI_FALSE; jboolean iscopy = JNI_FALSE;
const char* name = env->GetStringUTFChars(jname, &iscopy); if (jname) {
name = env->GetStringUTFChars(jname, &iscopy);
if (!name) { if (!name) {
JavaDOMGlobals::ThrowException(env, JavaDOMGlobals::ThrowException(env,
"Document.createAttribute: GetStringUTFChars failed"); "Document.createAttribute: GetStringUTFChars failed");
return NULL; return NULL;
} }
}
nsresult rv = doc->CreateAttribute(name, &ret); nsresult rv = doc->CreateAttribute(name, &ret);
if (iscopy == JNI_TRUE) if (iscopy == JNI_TRUE)
@ -119,14 +122,17 @@ JNIEXPORT jobject JNICALL Java_org_mozilla_dom_DocumentImpl_createCDATASection
return NULL; return NULL;
} }
const char* data = NULL;
nsIDOMCDATASection* ret = nsnull; nsIDOMCDATASection* ret = nsnull;
jboolean iscopy = JNI_FALSE; jboolean iscopy = JNI_FALSE;
const char* data = env->GetStringUTFChars(jdata, &iscopy); if (jdata) {
data = env->GetStringUTFChars(jdata, &iscopy);
if (!data) { if (!data) {
JavaDOMGlobals::ThrowException(env, JavaDOMGlobals::ThrowException(env,
"Document.createCDATASection: GetStringUTFChars failed"); "Document.createCDATASection: GetStringUTFChars failed");
return NULL; return NULL;
} }
}
nsresult rv = doc->CreateCDATASection(data, &ret); nsresult rv = doc->CreateCDATASection(data, &ret);
if (iscopy == JNI_TRUE) if (iscopy == JNI_TRUE)
@ -176,14 +182,17 @@ JNIEXPORT jobject JNICALL Java_org_mozilla_dom_DocumentImpl_createComment
return NULL; return NULL;
} }
const char* data = NULL;
nsIDOMComment* ret = nsnull; nsIDOMComment* ret = nsnull;
jboolean iscopy = JNI_FALSE; jboolean iscopy = JNI_FALSE;
const char* data = env->GetStringUTFChars(jdata, &iscopy); if (jdata) {
data = env->GetStringUTFChars(jdata, &iscopy);
if (!data) { if (!data) {
JavaDOMGlobals::ThrowException(env, JavaDOMGlobals::ThrowException(env,
"Document.createComment: GetStringUTFChars failed"); "Document.createComment: GetStringUTFChars failed");
return NULL; return NULL;
} }
}
nsresult rv = doc->CreateComment(data, &ret); nsresult rv = doc->CreateComment(data, &ret);
if (iscopy == JNI_TRUE) if (iscopy == JNI_TRUE)
@ -270,14 +279,17 @@ JNIEXPORT jobject JNICALL Java_org_mozilla_dom_DocumentImpl_createElement
return NULL; return NULL;
} }
const char* tagName = NULL;
nsIDOMElement* ret = nsnull; nsIDOMElement* ret = nsnull;
jboolean iscopy = JNI_FALSE; jboolean iscopy = JNI_FALSE;
const char* tagName = env->GetStringUTFChars(jtagName, &iscopy); if (jtagName) {
tagName = env->GetStringUTFChars(jtagName, &iscopy);
if (!tagName) { if (!tagName) {
JavaDOMGlobals::ThrowException(env, JavaDOMGlobals::ThrowException(env,
"Document.createElement: GetStringUTFChars failed"); "Document.createElement: GetStringUTFChars failed");
return NULL; return NULL;
} }
}
nsresult rv = doc->CreateElement(tagName, &ret); nsresult rv = doc->CreateElement(tagName, &ret);
if (iscopy == JNI_TRUE) if (iscopy == JNI_TRUE)
@ -328,14 +340,17 @@ JNIEXPORT jobject JNICALL Java_org_mozilla_dom_DocumentImpl_createEntityReferenc
return NULL; return NULL;
} }
const char* name = NULL;
nsIDOMEntityReference* ret = nsnull; nsIDOMEntityReference* ret = nsnull;
jboolean iscopy = JNI_FALSE; jboolean iscopy = JNI_FALSE;
const char* name = env->GetStringUTFChars(jname, &iscopy); if (jname) {
name = env->GetStringUTFChars(jname, &iscopy);
if (!name) { if (!name) {
JavaDOMGlobals::ThrowException(env, JavaDOMGlobals::ThrowException(env,
"Document.createEntityReference: GetStringUTFChars failed"); "Document.createEntityReference: GetStringUTFChars failed");
return NULL; return NULL;
} }
}
nsresult rv = doc->CreateEntityReference(name, &ret); nsresult rv = doc->CreateEntityReference(name, &ret);
if (iscopy == JNI_TRUE) if (iscopy == JNI_TRUE)
@ -386,22 +401,28 @@ JNIEXPORT jobject JNICALL Java_org_mozilla_dom_DocumentImpl_createProcessingInst
return NULL; return NULL;
} }
const char* target = NULL;
const char* data = NULL;
nsIDOMProcessingInstruction* ret = nsnull; nsIDOMProcessingInstruction* ret = nsnull;
jboolean iscopy = JNI_FALSE; jboolean iscopy = JNI_FALSE;
jboolean iscopy2 = JNI_FALSE; jboolean iscopy2 = JNI_FALSE;
const char* target = env->GetStringUTFChars(jtarget, &iscopy); if (jtarget) {
target = env->GetStringUTFChars(jtarget, &iscopy);
if (!target) { if (!target) {
JavaDOMGlobals::ThrowException(env, JavaDOMGlobals::ThrowException(env,
"Document.createProcessingInstruction: GetStringUTFChars target failed"); "Document.createProcessingInstruction: GetStringUTFChars target failed");
return NULL; return NULL;
} }
}
const char* data = env->GetStringUTFChars(jdata, &iscopy2); if (jdata) {
data = env->GetStringUTFChars(jdata, &iscopy2);
if (!data) { if (!data) {
JavaDOMGlobals::ThrowException(env, JavaDOMGlobals::ThrowException(env,
"Document.createProcessingInstruction: GetStringUTFChars data failed"); "Document.createProcessingInstruction: GetStringUTFChars data failed");
return NULL; return NULL;
} }
}
nsresult rv = doc->CreateProcessingInstruction(target, data, &ret); nsresult rv = doc->CreateProcessingInstruction(target, data, &ret);
if (iscopy2 == JNI_TRUE) if (iscopy2 == JNI_TRUE)
@ -454,14 +475,17 @@ JNIEXPORT jobject JNICALL Java_org_mozilla_dom_DocumentImpl_createTextNode
return NULL; return NULL;
} }
const char* data = NULL;
nsIDOMText* ret = nsnull; nsIDOMText* ret = nsnull;
jboolean iscopy = JNI_FALSE; jboolean iscopy = JNI_FALSE;
const char* data = env->GetStringUTFChars(jdata, &iscopy); if (jdata) {
data = env->GetStringUTFChars(jdata, &iscopy);
if (!data) { if (!data) {
JavaDOMGlobals::ThrowException(env, JavaDOMGlobals::ThrowException(env,
"Document.createAttribute: GetStringUTFChars failed"); "Document.createAttribute: GetStringUTFChars failed");
return NULL; return NULL;
} }
}
nsresult rv = doc->CreateTextNode(data, &ret); nsresult rv = doc->CreateTextNode(data, &ret);
if (iscopy == JNI_TRUE) if (iscopy == JNI_TRUE)
@ -588,14 +612,17 @@ JNIEXPORT jobject JNICALL Java_org_mozilla_dom_DocumentImpl_getElementsByTagName
return NULL; return NULL;
} }
const char* tagName = NULL;
nsIDOMNodeList* elements = nsnull; nsIDOMNodeList* elements = nsnull;
jboolean iscopy = JNI_FALSE; jboolean iscopy = JNI_FALSE;
const char* tagName = env->GetStringUTFChars(jtagName, &iscopy); if (jtagName) {
tagName = env->GetStringUTFChars(jtagName, &iscopy);
if (!tagName) { if (!tagName) {
JavaDOMGlobals::ThrowException(env, JavaDOMGlobals::ThrowException(env,
"Document.getElementsByTagName: GetStringUTFChars failed"); "Document.getElementsByTagName: GetStringUTFChars failed");
return NULL; return NULL;
} }
}
nsresult rv = doc->GetElementsByTagName(tagName, &elements); nsresult rv = doc->GetElementsByTagName(tagName, &elements);
if (iscopy == JNI_TRUE) if (iscopy == JNI_TRUE)

Просмотреть файл

@ -39,13 +39,16 @@ JNIEXPORT jstring JNICALL Java_org_mozilla_dom_ElementImpl_getAttribute
return NULL; return NULL;
} }
const char* cname = NULL;
jboolean iscopy = JNI_FALSE; jboolean iscopy = JNI_FALSE;
const char* cname = env->GetStringUTFChars(jname, &iscopy); if (jname) {
cname = env->GetStringUTFChars(jname, &iscopy);
if (!cname) { if (!cname) {
JavaDOMGlobals::ThrowException(env, JavaDOMGlobals::ThrowException(env,
"Element.getAttribute: GetStringUTFChars failed"); "Element.getAttribute: GetStringUTFChars failed");
return NULL; return NULL;
} }
}
nsString attr; nsString attr;
nsresult rv = element->GetAttribute(cname, attr); nsresult rv = element->GetAttribute(cname, attr);
@ -83,23 +86,28 @@ JNIEXPORT jobject JNICALL Java_org_mozilla_dom_ElementImpl_getAttributeNode
return NULL; return NULL;
} }
const char* cname = NULL;
jboolean iscopy = JNI_FALSE; jboolean iscopy = JNI_FALSE;
const char* cname = env->GetStringUTFChars(jname, &iscopy); if (jname) {
cname = env->GetStringUTFChars(jname, &iscopy);
if (!cname) { if (!cname) {
JavaDOMGlobals::ThrowException(env, JavaDOMGlobals::ThrowException(env,
"Element.getAttributeNode: GetStringUTFChars failed"); "Element.getAttributeNode: GetStringUTFChars failed");
return NULL; return NULL;
} }
}
nsIDOMAttr* attr = nsnull; nsIDOMAttr* attr = nsnull;
nsresult rv = element->GetAttributeNode(cname, &attr); nsresult rv = element->GetAttributeNode(cname, &attr);
if (iscopy == JNI_TRUE) if (iscopy == JNI_TRUE)
env->ReleaseStringUTFChars(jname, cname); env->ReleaseStringUTFChars(jname, cname);
if (NS_FAILED(rv) || !attr) { if (NS_FAILED(rv)) {
JavaDOMGlobals::ThrowException(env, JavaDOMGlobals::ThrowException(env,
"Element.getAttributeNode: failed", rv); "Element.getAttributeNode: failed", rv);
return NULL; return NULL;
} }
if (!attr)
return NULL;
jobject jattr = env->AllocObject(JavaDOMGlobals::attrClass); jobject jattr = env->AllocObject(JavaDOMGlobals::attrClass);
if (!jattr) { if (!jattr) {
@ -135,13 +143,16 @@ JNIEXPORT jobject JNICALL Java_org_mozilla_dom_ElementImpl_getElementsByTagName
return NULL; return NULL;
} }
const char* cname = NULL;
jboolean iscopy = JNI_FALSE; jboolean iscopy = JNI_FALSE;
const char* cname = env->GetStringUTFChars(jname, &iscopy); if (jname) {
cname = env->GetStringUTFChars(jname, &iscopy);
if (!cname) { if (!cname) {
JavaDOMGlobals::ThrowException(env, JavaDOMGlobals::ThrowException(env,
"Element.getElementsByTagName: GetStringUTFChars failed"); "Element.getElementsByTagName: GetStringUTFChars failed");
return NULL; return NULL;
} }
}
nsIDOMNodeList* nodes = nsnull; nsIDOMNodeList* nodes = nsnull;
nsresult rv = element->GetElementsByTagName(cname, &nodes); nsresult rv = element->GetElementsByTagName(cname, &nodes);
@ -340,21 +351,27 @@ JNIEXPORT void JNICALL Java_org_mozilla_dom_ElementImpl_setAttribute
return; return;
} }
const char* name = NULL;
const char* value = NULL;
jboolean iscopy = JNI_FALSE; jboolean iscopy = JNI_FALSE;
const char* name = env->GetStringUTFChars(jname, &iscopy); if (jname) {
name = env->GetStringUTFChars(jname, &iscopy);
if (!name) { if (!name) {
JavaDOMGlobals::ThrowException(env, JavaDOMGlobals::ThrowException(env,
"Element.setAttribute: GetStringUTFChars name failed"); "Element.setAttribute: GetStringUTFChars name failed");
return; return;
} }
}
jboolean iscopy2 = JNI_FALSE; jboolean iscopy2 = JNI_FALSE;
const char* value = env->GetStringUTFChars(jvalue, &iscopy2); if (jvalue) {
value = env->GetStringUTFChars(jvalue, &iscopy2);
if (!value) { if (!value) {
JavaDOMGlobals::ThrowException(env, JavaDOMGlobals::ThrowException(env,
"Element.setAttribute: GetStringUTFChars name failed"); "Element.setAttribute: GetStringUTFChars name failed");
return; return;
} }
}
nsresult rv = element->SetAttribute(name, value); nsresult rv = element->SetAttribute(name, value);
if (iscopy2 == JNI_TRUE) if (iscopy2 == JNI_TRUE)

Просмотреть файл

@ -34,6 +34,9 @@ JNIEXPORT jboolean JNICALL Java_org_mozilla_dom_NodeImpl_XPCOM_1equals
{ {
jboolean b_retFlag = JNI_FALSE; jboolean b_retFlag = JNI_FALSE;
if (!nodeArg)
return b_retFlag;
nsIDOMNode* p_thisNode = nsIDOMNode* p_thisNode =
(nsIDOMNode*) env->GetLongField(jthis, JavaDOMGlobals::nodePtrFID); (nsIDOMNode*) env->GetLongField(jthis, JavaDOMGlobals::nodePtrFID);
if (!p_thisNode) { if (!p_thisNode) {
@ -138,13 +141,16 @@ JNIEXPORT jobject JNICALL Java_org_mozilla_dom_NodeImpl_appendChild
return NULL; return NULL;
} }
nsIDOMNode* child = (nsIDOMNode*) nsIDOMNode* child = NULL;
if (jchild) {
child = (nsIDOMNode*)
env->GetLongField(jchild, JavaDOMGlobals::nodePtrFID); env->GetLongField(jchild, JavaDOMGlobals::nodePtrFID);
if (!child) { if (!child) {
JavaDOMGlobals::ThrowException(env, JavaDOMGlobals::ThrowException(env,
"Node.appendChild: NULL child pointer"); "Node.appendChild: NULL child pointer");
return NULL; return NULL;
} }
}
nsIDOMNode* ret = nsnull; nsIDOMNode* ret = nsnull;
nsresult rv = node->AppendChild(child, &ret); nsresult rv = node->AppendChild(child, &ret);
@ -663,21 +669,27 @@ JNIEXPORT jobject JNICALL Java_org_mozilla_dom_NodeImpl_insertBefore
return NULL; return NULL;
} }
nsIDOMNode* newChild = (nsIDOMNode*) nsIDOMNode* newChild = NULL;
if (jnewChild) {
newChild = (nsIDOMNode*)
env->GetLongField(jnewChild, JavaDOMGlobals::nodePtrFID); env->GetLongField(jnewChild, JavaDOMGlobals::nodePtrFID);
if (!newChild) { if (!newChild) {
JavaDOMGlobals::ThrowException(env, JavaDOMGlobals::ThrowException(env,
"Node.insertBefore: NULL newChild pointer"); "Node.insertBefore: NULL newChild pointer");
return NULL; return NULL;
} }
}
nsIDOMNode* refChild = (nsIDOMNode*) nsIDOMNode* refChild = NULL;
if (jrefChild) {
refChild = (nsIDOMNode*)
env->GetLongField(jrefChild, JavaDOMGlobals::nodePtrFID); env->GetLongField(jrefChild, JavaDOMGlobals::nodePtrFID);
if (!refChild) { if (!refChild) {
JavaDOMGlobals::ThrowException(env, JavaDOMGlobals::ThrowException(env,
"Node.insertBefore: NULL refChild pointer"); "Node.insertBefore: NULL refChild pointer");
return NULL; return NULL;
} }
}
nsIDOMNode* ret = nsnull; nsIDOMNode* ret = nsnull;
nsresult rv = node->InsertBefore(newChild, refChild, &ret); nsresult rv = node->InsertBefore(newChild, refChild, &ret);
@ -714,13 +726,16 @@ JNIEXPORT jobject JNICALL Java_org_mozilla_dom_NodeImpl_removeChild
return NULL; return NULL;
} }
nsIDOMNode* oldChild = (nsIDOMNode*) nsIDOMNode* oldChild = NULL;
if (joldChild) {
oldChild = (nsIDOMNode*)
env->GetLongField(joldChild, JavaDOMGlobals::nodePtrFID); env->GetLongField(joldChild, JavaDOMGlobals::nodePtrFID);
if (!oldChild) { if (!oldChild) {
JavaDOMGlobals::ThrowException(env, JavaDOMGlobals::ThrowException(env,
"Node.removeChild: NULL oldChild pointer"); "Node.removeChild: NULL oldChild pointer");
return NULL; return NULL;
} }
}
nsIDOMNode* ret = nsnull; nsIDOMNode* ret = nsnull;
nsresult rv = node->RemoveChild(oldChild, &ret); nsresult rv = node->RemoveChild(oldChild, &ret);
@ -755,21 +770,27 @@ JNIEXPORT jobject JNICALL Java_org_mozilla_dom_NodeImpl_replaceChild
return NULL; return NULL;
} }
nsIDOMNode* newChild = (nsIDOMNode*) nsIDOMNode* newChild = NULL;
if (jnewChild) {
newChild = (nsIDOMNode*)
env->GetLongField(jnewChild, JavaDOMGlobals::nodePtrFID); env->GetLongField(jnewChild, JavaDOMGlobals::nodePtrFID);
if (!newChild) { if (!newChild) {
JavaDOMGlobals::ThrowException(env, JavaDOMGlobals::ThrowException(env,
"Node.replaceChild: NULL newChild pointer"); "Node.replaceChild: NULL newChild pointer");
return NULL; return NULL;
} }
}
nsIDOMNode* oldChild = (nsIDOMNode*) nsIDOMNode* oldChild = NULL;
if (joldChild) {
oldChild = (nsIDOMNode*)
env->GetLongField(joldChild, JavaDOMGlobals::nodePtrFID); env->GetLongField(joldChild, JavaDOMGlobals::nodePtrFID);
if (!oldChild) { if (!oldChild) {
JavaDOMGlobals::ThrowException(env, JavaDOMGlobals::ThrowException(env,
"Node.replaceChild: NULL oldChild pointer"); "Node.replaceChild: NULL oldChild pointer");
return NULL; return NULL;
} }
}
nsIDOMNode* ret = nsnull; nsIDOMNode* ret = nsnull;
nsresult rv = node->ReplaceChild(newChild, oldChild, &ret); nsresult rv = node->ReplaceChild(newChild, oldChild, &ret);
@ -806,13 +827,16 @@ JNIEXPORT void JNICALL Java_org_mozilla_dom_NodeImpl_setNodeValue
return; return;
} }
const char* value = NULL;
jboolean iscopy = JNI_FALSE; jboolean iscopy = JNI_FALSE;
const char* value = env->GetStringUTFChars(jvalue, &iscopy); if (jvalue) {
value = env->GetStringUTFChars(jvalue, &iscopy);
if (!value) { if (!value) {
JavaDOMGlobals::ThrowException(env, JavaDOMGlobals::ThrowException(env,
"Node.setNodeValue: GetStringUTFChars failed"); "Node.setNodeValue: GetStringUTFChars failed");
return; return;
} }
}
nsresult rv = node->SetNodeValue(value); nsresult rv = node->SetNodeValue(value);
if (iscopy == JNI_TRUE) if (iscopy == JNI_TRUE)

Просмотреть файл

@ -72,7 +72,7 @@ JNIEXPORT jstring JNICALL Java_org_mozilla_dom_ProcessingInstructionImpl_getTarg
} }
nsString ret; nsString ret;
nsresult rv = pi->GetData(ret); nsresult rv = pi->GetTarget(ret);
if (NS_FAILED(rv)) { if (NS_FAILED(rv)) {
JavaDOMGlobals::ThrowException(env, JavaDOMGlobals::ThrowException(env,
"ProcessingInstruction.getTarget: failed", rv); "ProcessingInstruction.getTarget: failed", rv);
@ -105,13 +105,17 @@ JNIEXPORT void JNICALL Java_org_mozilla_dom_ProcessingInstructionImpl_setData
return; return;
} }
const char* data = NULL;
jboolean iscopy = JNI_FALSE; jboolean iscopy = JNI_FALSE;
const char* data = env->GetStringUTFChars(jdata, &iscopy); if (jdata) {
data = env->GetStringUTFChars(jdata, &iscopy);
if (!data) { if (!data) {
JavaDOMGlobals::ThrowException(env, JavaDOMGlobals::ThrowException(env,
"ProcessingInstruction.setData: GetStringUTFChars failed"); "ProcessingInstruction.setData: GetStringUTFChars failed");
return; return;
} }
}
nsresult rv = pi->SetData(data); nsresult rv = pi->SetData(data);
if (iscopy == JNI_TRUE) if (iscopy == JNI_TRUE)
env->ReleaseStringUTFChars(jdata, data); env->ReleaseStringUTFChars(jdata, data);