changed fix to bug 13338.

now check for null pointers in Java DOM instead of
passing null references to coreDOM
This commit is contained in:
sdv%sparc.spb.su 2000-02-11 07:58:12 +00:00
parent a2a99ee0c3
commit e720b68a19
7 changed files with 160 additions and 247 deletions

View File

@ -127,21 +127,18 @@ JNIEXPORT void JNICALL Java_org_mozilla_dom_AttrImpl_setValue
{
nsIDOMAttr* attr = (nsIDOMAttr*)
env->GetLongField(jthis, JavaDOMGlobals::nodePtrFID);
if (!attr) {
PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR,
("Attr.setValue: NULL pointer\n"));
if (!attr || !jval) {
JavaDOMGlobals::ThrowException(env,
"Attr.setValue: NULL pointer\n");
return;
}
const char* cvalue = NULL;
jboolean iscopy = JNI_FALSE;
if (jval) {
cvalue = env->GetStringUTFChars(jval, &iscopy);
if (!cvalue) {
PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR,
("Attr.setValue: GetStringUTFChars failed\n"));
return;
}
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);

View File

@ -35,21 +35,18 @@ JNIEXPORT void JNICALL Java_org_mozilla_dom_CharacterDataImpl_appendData
{
nsIDOMCharacterData* data = (nsIDOMCharacterData*)
env->GetLongField(jthis, JavaDOMGlobals::nodePtrFID);
if (!data) {
if (!data || !jvalue) {
JavaDOMGlobals::ThrowException(env,
"CharacterData.appendData: NULL pointer");
return;
}
const char* value = NULL;
jboolean iscopy = JNI_FALSE;
if (jvalue) {
value = env->GetStringUTFChars(jvalue, &iscopy);
if (!value) {
JavaDOMGlobals::ThrowException(env,
"CharacterData.appendData: GetStringUTFChars failed");
return;
}
const char* value = env->GetStringUTFChars(jvalue, &iscopy);
if (!value) {
JavaDOMGlobals::ThrowException(env,
"CharacterData.appendData: GetStringUTFChars failed");
return;
}
nsresult rv = data->AppendData(value);
@ -178,21 +175,18 @@ JNIEXPORT void JNICALL Java_org_mozilla_dom_CharacterDataImpl_insertData
{
nsIDOMCharacterData* data = (nsIDOMCharacterData*)
env->GetLongField(jthis, JavaDOMGlobals::nodePtrFID);
if (!data) {
if (!data || !jvalue) {
JavaDOMGlobals::ThrowException(env,
"CharacterData.insertData: NULL pointer");
return;
}
const char* value = NULL;
jboolean iscopy = JNI_FALSE;
if (jvalue) {
value = env->GetStringUTFChars(jvalue, &iscopy);
if (!value) {
JavaDOMGlobals::ThrowException(env,
"CharacterData.insertData: GetStringUTFChars failed");
return;
}
const char* value = env->GetStringUTFChars(jvalue, &iscopy);
if (!value) {
JavaDOMGlobals::ThrowException(env,
"CharacterData.insertData: GetStringUTFChars failed");
return;
}
nsresult rv = data->InsertData((PRUint32) offset, value);
@ -229,21 +223,18 @@ JNIEXPORT void JNICALL Java_org_mozilla_dom_CharacterDataImpl_replaceData
nsIDOMCharacterData* data = (nsIDOMCharacterData*)
env->GetLongField(jthis, JavaDOMGlobals::nodePtrFID);
if (!data) {
if (!data || !jvalue) {
JavaDOMGlobals::ThrowException(env,
"CharacterData.replaceData: NULL pointer");
return;
}
const char* value = NULL;
jboolean iscopy = JNI_FALSE;
if (jvalue) {
value = env->GetStringUTFChars(jvalue, &iscopy);
if (!value) {
JavaDOMGlobals::ThrowException(env,
"CharacterData.replaceData: GetStringUTFChars failed");
return;
}
const char* value = env->GetStringUTFChars(jvalue, &iscopy);
if (!value) {
JavaDOMGlobals::ThrowException(env,
"CharacterData.replaceData: GetStringUTFChars failed");
return;
}
nsresult rv = data->ReplaceData((PRUint32) offset, (PRUint32) count, value);
@ -272,21 +263,18 @@ JNIEXPORT void JNICALL Java_org_mozilla_dom_CharacterDataImpl_setData
{
nsIDOMCharacterData* data = (nsIDOMCharacterData*)
env->GetLongField(jthis, JavaDOMGlobals::nodePtrFID);
if (!data) {
if (!data || !jvalue) {
JavaDOMGlobals::ThrowException(env,
"CharacterData.setData: NULL pointer");
return;
}
const char* value = NULL;
jboolean iscopy = JNI_FALSE;
if (jvalue) {
value = env->GetStringUTFChars(jvalue, &iscopy);
if (!value) {
JavaDOMGlobals::ThrowException(env,
"CharacterData.setData: GetStringUTFChars failed");
return;
}
const char* value = env->GetStringUTFChars(jvalue, &iscopy);
if (!value) {
JavaDOMGlobals::ThrowException(env,
"CharacterData.setData: GetStringUTFChars failed");
return;
}
nsresult rv = data->SetData(value);

View File

@ -142,32 +142,26 @@ JNIEXPORT jboolean JNICALL Java_org_mozilla_dom_DOMImplementationImpl_hasFeature
{
nsIDOMDOMImplementation* dom = (nsIDOMDOMImplementation*)
env->GetLongField(jthis, JavaDOMGlobals::domImplementationPtrFID);
if (!dom) {
if (!dom || !jversion || !jfeature) {
PR_LOG(JavaDOMGlobals::log, PR_LOG_WARNING,
("DOMImplementation.hasFeature: NULL pointer\n"));
return JNI_FALSE;
}
const char* feature = NULL;
jboolean iscopy = 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* 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;
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;
}
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;
}
PRBool ret = PR_FALSE;

View File

@ -60,22 +60,19 @@ JNIEXPORT jobject JNICALL Java_org_mozilla_dom_DocumentImpl_createAttribute
{
nsIDOMDocument* doc = (nsIDOMDocument*)
env->GetLongField(jthis, JavaDOMGlobals::nodePtrFID);
if (!doc) {
if (!doc || !jname) {
JavaDOMGlobals::ThrowException(env,
"Document.createAttribute: NULL pointer");
return NULL;
}
const char* name = NULL;
nsIDOMAttr* ret = nsnull;
jboolean iscopy = JNI_FALSE;
if (jname) {
name = env->GetStringUTFChars(jname, &iscopy);
if (!name) {
JavaDOMGlobals::ThrowException(env,
"Document.createAttribute: GetStringUTFChars failed");
return NULL;
}
const char* name = env->GetStringUTFChars(jname, &iscopy);
if (!name) {
JavaDOMGlobals::ThrowException(env,
"Document.createAttribute: GetStringUTFChars failed");
return NULL;
}
nsresult rv = doc->CreateAttribute(name, &ret);
@ -120,22 +117,19 @@ JNIEXPORT jobject JNICALL Java_org_mozilla_dom_DocumentImpl_createCDATASection
{
nsIDOMDocument* doc = (nsIDOMDocument*)
env->GetLongField(jthis, JavaDOMGlobals::nodePtrFID);
if (!doc) {
if (!doc || !jdata) {
JavaDOMGlobals::ThrowException(env,
"Document.createCDATASection: NULL pointer");
return NULL;
}
const char* data = NULL;
nsIDOMCDATASection* ret = nsnull;
jboolean iscopy = JNI_FALSE;
if (jdata) {
data = env->GetStringUTFChars(jdata, &iscopy);
if (!data) {
JavaDOMGlobals::ThrowException(env,
"Document.createCDATASection: GetStringUTFChars failed");
return NULL;
}
const char* data = env->GetStringUTFChars(jdata, &iscopy);
if (!data) {
JavaDOMGlobals::ThrowException(env,
"Document.createCDATASection: GetStringUTFChars failed");
return NULL;
}
nsresult rv = doc->CreateCDATASection(data, &ret);
@ -179,22 +173,19 @@ JNIEXPORT jobject JNICALL Java_org_mozilla_dom_DocumentImpl_createComment
{
nsIDOMDocument* doc = (nsIDOMDocument*)
env->GetLongField(jthis, JavaDOMGlobals::nodePtrFID);
if (!doc) {
if (!doc || !jdata) {
JavaDOMGlobals::ThrowException(env,
"Document.createComment: NULL pointer");
return NULL;
}
const char* data = NULL;
nsIDOMComment* ret = nsnull;
jboolean iscopy = JNI_FALSE;
if (jdata) {
data = env->GetStringUTFChars(jdata, &iscopy);
if (!data) {
JavaDOMGlobals::ThrowException(env,
"Document.createComment: GetStringUTFChars failed");
return NULL;
}
const char* data = env->GetStringUTFChars(jdata, &iscopy);
if (!data) {
JavaDOMGlobals::ThrowException(env,
"Document.createComment: GetStringUTFChars failed");
return NULL;
}
nsresult rv = doc->CreateComment(data, &ret);
@ -276,22 +267,19 @@ JNIEXPORT jobject JNICALL Java_org_mozilla_dom_DocumentImpl_createElement
{
nsIDOMDocument* doc = (nsIDOMDocument*)
env->GetLongField(jthis, JavaDOMGlobals::nodePtrFID);
if (!doc) {
if (!doc || !jtagName) {
JavaDOMGlobals::ThrowException(env,
"Document.createElement: NULL pointer");
return NULL;
}
const char* tagName = NULL;
nsIDOMElement* ret = nsnull;
jboolean iscopy = JNI_FALSE;
if (jtagName) {
tagName = env->GetStringUTFChars(jtagName, &iscopy);
if (!tagName) {
JavaDOMGlobals::ThrowException(env,
"Document.createElement: GetStringUTFChars failed");
return NULL;
}
const char* tagName = env->GetStringUTFChars(jtagName, &iscopy);
if (!tagName) {
JavaDOMGlobals::ThrowException(env,
"Document.createElement: GetStringUTFChars failed");
return NULL;
}
nsresult rv = doc->CreateElement(tagName, &ret);
@ -336,22 +324,19 @@ JNIEXPORT jobject JNICALL Java_org_mozilla_dom_DocumentImpl_createEntityReferenc
{
nsIDOMDocument* doc = (nsIDOMDocument*)
env->GetLongField(jthis, JavaDOMGlobals::nodePtrFID);
if (!doc) {
if (!doc || !jname) {
JavaDOMGlobals::ThrowException(env,
"Document.createEntityReference: NULL pointer");
return NULL;
}
const char* name = NULL;
nsIDOMEntityReference* ret = nsnull;
jboolean iscopy = JNI_FALSE;
if (jname) {
name = env->GetStringUTFChars(jname, &iscopy);
if (!name) {
JavaDOMGlobals::ThrowException(env,
"Document.createEntityReference: GetStringUTFChars failed");
return NULL;
}
const char* name = env->GetStringUTFChars(jname, &iscopy);
if (!name) {
JavaDOMGlobals::ThrowException(env,
"Document.createEntityReference: GetStringUTFChars failed");
return NULL;
}
nsresult rv = doc->CreateEntityReference(name, &ret);
@ -397,33 +382,27 @@ JNIEXPORT jobject JNICALL Java_org_mozilla_dom_DocumentImpl_createProcessingInst
{
nsIDOMDocument* doc = (nsIDOMDocument*)
env->GetLongField(jthis, JavaDOMGlobals::nodePtrFID);
if (!doc) {
if (!doc || !jtarget || !jdata) {
JavaDOMGlobals::ThrowException(env,
"Document.createProcessingInstruction: NULL pointer");
return NULL;
}
const char* target = NULL;
const char* data = NULL;
nsIDOMProcessingInstruction* ret = nsnull;
jboolean iscopy = JNI_FALSE;
jboolean iscopy2 = JNI_FALSE;
if (jtarget) {
target = env->GetStringUTFChars(jtarget, &iscopy);
if (!target) {
JavaDOMGlobals::ThrowException(env,
"Document.createProcessingInstruction: GetStringUTFChars target failed");
return NULL;
}
const char* target = env->GetStringUTFChars(jtarget, &iscopy);
if (!target) {
JavaDOMGlobals::ThrowException(env,
"Document.createProcessingInstruction: GetStringUTFChars target failed");
return NULL;
}
if (jdata) {
data = env->GetStringUTFChars(jdata, &iscopy2);
if (!data) {
JavaDOMGlobals::ThrowException(env,
"Document.createProcessingInstruction: GetStringUTFChars data failed");
return NULL;
}
const char* data = env->GetStringUTFChars(jdata, &iscopy2);
if (!data) {
JavaDOMGlobals::ThrowException(env,
"Document.createProcessingInstruction: GetStringUTFChars data failed");
return NULL;
}
nsresult rv = doc->CreateProcessingInstruction(target, data, &ret);
@ -471,22 +450,19 @@ JNIEXPORT jobject JNICALL Java_org_mozilla_dom_DocumentImpl_createTextNode
{
nsIDOMDocument* doc = (nsIDOMDocument*)
env->GetLongField(jthis, JavaDOMGlobals::nodePtrFID);
if (!doc) {
if (!doc || !jdata) {
JavaDOMGlobals::ThrowException(env,
"Document.createTextNode: NULL pointer");
return NULL;
}
const char* data = NULL;
nsIDOMText* ret = nsnull;
jboolean iscopy = JNI_FALSE;
if (jdata) {
data = env->GetStringUTFChars(jdata, &iscopy);
if (!data) {
JavaDOMGlobals::ThrowException(env,
"Document.createAttribute: GetStringUTFChars failed");
return NULL;
}
const char* data = env->GetStringUTFChars(jdata, &iscopy);
if (!data) {
JavaDOMGlobals::ThrowException(env,
"Document.createTextNode: GetStringUTFChars failed");
return NULL;
}
nsresult rv = doc->CreateTextNode(data, &ret);
@ -608,22 +584,19 @@ JNIEXPORT jobject JNICALL Java_org_mozilla_dom_DocumentImpl_getElementsByTagName
{
nsIDOMDocument* doc = (nsIDOMDocument*)
env->GetLongField(jthis, JavaDOMGlobals::nodePtrFID);
if (!doc) {
if (!doc || !jtagName) {
JavaDOMGlobals::ThrowException(env,
"Document.getElementsByTagName: NULL pointer");
return NULL;
}
const char* tagName = NULL;
nsIDOMNodeList* elements = nsnull;
jboolean iscopy = JNI_FALSE;
if (jtagName) {
tagName = env->GetStringUTFChars(jtagName, &iscopy);
if (!tagName) {
JavaDOMGlobals::ThrowException(env,
"Document.getElementsByTagName: GetStringUTFChars failed");
return NULL;
}
const char* tagName = env->GetStringUTFChars(jtagName, &iscopy);
if (!tagName) {
JavaDOMGlobals::ThrowException(env,
"Document.getElementsByTagName: GetStringUTFChars failed");
return NULL;
}
nsresult rv = doc->GetElementsByTagName(tagName, &elements);

View File

@ -38,21 +38,18 @@ JNIEXPORT jstring JNICALL Java_org_mozilla_dom_ElementImpl_getAttribute
{
nsIDOMElement* element = (nsIDOMElement*)
env->GetLongField(jthis, JavaDOMGlobals::nodePtrFID);
if (!element) {
if (!element || !jname) {
JavaDOMGlobals::ThrowException(env,
"Element.getAttribute: NULL pointer");
return NULL;
}
const char* cname = NULL;
jboolean iscopy = JNI_FALSE;
if (jname) {
cname = env->GetStringUTFChars(jname, &iscopy);
if (!cname) {
JavaDOMGlobals::ThrowException(env,
const char* cname = env->GetStringUTFChars(jname, &iscopy);
if (!cname) {
JavaDOMGlobals::ThrowException(env,
"Element.getAttribute: GetStringUTFChars failed");
return NULL;
}
return NULL;
}
nsString attr;
@ -85,21 +82,18 @@ JNIEXPORT jobject JNICALL Java_org_mozilla_dom_ElementImpl_getAttributeNode
{
nsIDOMElement* element = (nsIDOMElement*)
env->GetLongField(jthis, JavaDOMGlobals::nodePtrFID);
if (!element) {
if (!element || !jname) {
JavaDOMGlobals::ThrowException(env,
"Element.getAttributeNode: NULL pointer");
return NULL;
}
const char* cname = NULL;
jboolean iscopy = JNI_FALSE;
if (jname) {
cname = env->GetStringUTFChars(jname, &iscopy);
if (!cname) {
JavaDOMGlobals::ThrowException(env,
"Element.getAttributeNode: GetStringUTFChars failed");
return NULL;
}
const char* cname = env->GetStringUTFChars(jname, &iscopy);
if (!cname) {
JavaDOMGlobals::ThrowException(env,
"Element.getAttributeNode: GetStringUTFChars failed");
return NULL;
}
nsIDOMAttr* attr = nsnull;
@ -142,21 +136,18 @@ JNIEXPORT jobject JNICALL Java_org_mozilla_dom_ElementImpl_getElementsByTagName
{
nsIDOMElement* element = (nsIDOMElement*)
env->GetLongField(jthis, JavaDOMGlobals::nodePtrFID);
if (!element) {
if (!element || !jname) {
JavaDOMGlobals::ThrowException(env,
"Element.getElementsByTagName: NULL pointer");
return NULL;
}
const char* cname = NULL;
jboolean iscopy = JNI_FALSE;
if (jname) {
cname = env->GetStringUTFChars(jname, &iscopy);
if (!cname) {
JavaDOMGlobals::ThrowException(env,
const char* cname = env->GetStringUTFChars(jname, &iscopy);
if (!cname) {
JavaDOMGlobals::ThrowException(env,
"Element.getElementsByTagName: GetStringUTFChars failed");
return NULL;
}
return NULL;
}
nsIDOMNodeList* nodes = nsnull;
@ -349,32 +340,26 @@ JNIEXPORT void JNICALL Java_org_mozilla_dom_ElementImpl_setAttribute
{
nsIDOMElement* element = (nsIDOMElement*)
env->GetLongField(jthis, JavaDOMGlobals::nodePtrFID);
if (!element) {
if (!element || !jname || !jvalue) {
JavaDOMGlobals::ThrowException(env,
"Element.setAttribute: NULL pointer");
return;
}
const char* name = NULL;
const char* value = NULL;
jboolean iscopy = JNI_FALSE;
if (jname) {
name = env->GetStringUTFChars(jname, &iscopy);
if (!name) {
JavaDOMGlobals::ThrowException(env,
"Element.setAttribute: GetStringUTFChars name failed");
const char* name = env->GetStringUTFChars(jname, &iscopy);
if (!name) {
JavaDOMGlobals::ThrowException(env,
"Element.setAttribute: GetStringUTFChars name failed");
return;
}
}
jboolean iscopy2 = JNI_FALSE;
if (jvalue) {
value = env->GetStringUTFChars(jvalue, &iscopy2);
if (!value) {
JavaDOMGlobals::ThrowException(env,
const char* value = env->GetStringUTFChars(jvalue, &iscopy2);
if (!value) {
JavaDOMGlobals::ThrowException(env,
"Element.setAttribute: GetStringUTFChars name failed");
return;
}
return;
}
nsresult rv = element->SetAttribute(name, value);

View File

@ -140,21 +140,18 @@ JNIEXPORT jobject JNICALL Java_org_mozilla_dom_NodeImpl_appendChild
{
nsIDOMNode* node = (nsIDOMNode*)
env->GetLongField(jthis, JavaDOMGlobals::nodePtrFID);
if (!node) {
if (!node || !jchild) {
JavaDOMGlobals::ThrowException(env,
"Node.appendChild: NULL pointer");
return NULL;
}
nsIDOMNode* child = NULL;
if (jchild) {
child = (nsIDOMNode*)
nsIDOMNode* child = (nsIDOMNode*)
env->GetLongField(jchild, JavaDOMGlobals::nodePtrFID);
if (!child) {
JavaDOMGlobals::ThrowException(env,
if (!child) {
JavaDOMGlobals::ThrowException(env,
"Node.appendChild: NULL child pointer");
return NULL;
}
return NULL;
}
nsIDOMNode* ret = nsnull;
@ -667,32 +664,26 @@ JNIEXPORT jobject JNICALL Java_org_mozilla_dom_NodeImpl_insertBefore
{
nsIDOMNode* node = (nsIDOMNode*)
env->GetLongField(jthis, JavaDOMGlobals::nodePtrFID);
if (!node) {
if (!node || !jnewChild || !jrefChild) {
JavaDOMGlobals::ThrowException(env,
"Node.insertBefore: NULL pointer");
return NULL;
}
nsIDOMNode* newChild = NULL;
if (jnewChild) {
newChild = (nsIDOMNode*)
nsIDOMNode* newChild = (nsIDOMNode*)
env->GetLongField(jnewChild, JavaDOMGlobals::nodePtrFID);
if (!newChild) {
JavaDOMGlobals::ThrowException(env,
if (!newChild) {
JavaDOMGlobals::ThrowException(env,
"Node.insertBefore: NULL newChild pointer");
return NULL;
}
return NULL;
}
nsIDOMNode* refChild = NULL;
if (jrefChild) {
refChild = (nsIDOMNode*)
nsIDOMNode* refChild = (nsIDOMNode*)
env->GetLongField(jrefChild, JavaDOMGlobals::nodePtrFID);
if (!refChild) {
JavaDOMGlobals::ThrowException(env,
"Node.insertBefore: NULL refChild pointer");
return NULL;
}
if (!refChild) {
JavaDOMGlobals::ThrowException(env,
"Node.insertBefore: NULL refChild pointer");
return NULL;
}
nsIDOMNode* ret = nsnull;
@ -724,21 +715,18 @@ JNIEXPORT jobject JNICALL Java_org_mozilla_dom_NodeImpl_removeChild
{
nsIDOMNode* node = (nsIDOMNode*)
env->GetLongField(jthis, JavaDOMGlobals::nodePtrFID);
if (!node) {
if (!node || !joldChild) {
JavaDOMGlobals::ThrowException(env,
"Node.removeChild: NULL pointer");
return NULL;
}
nsIDOMNode* oldChild = NULL;
if (joldChild) {
oldChild = (nsIDOMNode*)
nsIDOMNode* oldChild = (nsIDOMNode*)
env->GetLongField(joldChild, JavaDOMGlobals::nodePtrFID);
if (!oldChild) {
JavaDOMGlobals::ThrowException(env,
if (!oldChild) {
JavaDOMGlobals::ThrowException(env,
"Node.removeChild: NULL oldChild pointer");
return NULL;
}
return NULL;
}
nsIDOMNode* ret = nsnull;
@ -768,32 +756,26 @@ JNIEXPORT jobject JNICALL Java_org_mozilla_dom_NodeImpl_replaceChild
{
nsIDOMNode* node = (nsIDOMNode*)
env->GetLongField(jthis, JavaDOMGlobals::nodePtrFID);
if (!node) {
if (!node || !jnewChild || !joldChild) {
JavaDOMGlobals::ThrowException(env,
"Node.replaceChild: NULL pointer");
return NULL;
}
nsIDOMNode* newChild = NULL;
if (jnewChild) {
newChild = (nsIDOMNode*)
nsIDOMNode* newChild = (nsIDOMNode*)
env->GetLongField(jnewChild, JavaDOMGlobals::nodePtrFID);
if (!newChild) {
JavaDOMGlobals::ThrowException(env,
if (!newChild) {
JavaDOMGlobals::ThrowException(env,
"Node.replaceChild: NULL newChild pointer");
return NULL;
}
return NULL;
}
nsIDOMNode* oldChild = NULL;
if (joldChild) {
oldChild = (nsIDOMNode*)
nsIDOMNode* oldChild = (nsIDOMNode*)
env->GetLongField(joldChild, JavaDOMGlobals::nodePtrFID);
if (!oldChild) {
JavaDOMGlobals::ThrowException(env,
if (!oldChild) {
JavaDOMGlobals::ThrowException(env,
"Node.replaceChild: NULL oldChild pointer");
return NULL;
}
return NULL;
}
nsIDOMNode* ret = nsnull;
@ -825,21 +807,18 @@ JNIEXPORT void JNICALL Java_org_mozilla_dom_NodeImpl_setNodeValue
{
nsIDOMNode* node = (nsIDOMNode*)
env->GetLongField(jthis, JavaDOMGlobals::nodePtrFID);
if (!node) {
if (!node || !jvalue) {
JavaDOMGlobals::ThrowException(env,
"Node.setNodeValue: NULL pointer");
return;
}
const char* value = NULL;
jboolean iscopy = JNI_FALSE;
if (jvalue) {
value = env->GetStringUTFChars(jvalue, &iscopy);
if (!value) {
JavaDOMGlobals::ThrowException(env,
const char* value = env->GetStringUTFChars(jvalue, &iscopy);
if (!value) {
JavaDOMGlobals::ThrowException(env,
"Node.setNodeValue: GetStringUTFChars failed");
return;
}
return;
}
nsresult rv = node->SetNodeValue(value);

View File

@ -104,21 +104,18 @@ JNIEXPORT void JNICALL Java_org_mozilla_dom_ProcessingInstructionImpl_setData
{
nsIDOMProcessingInstruction* pi = (nsIDOMProcessingInstruction*)
env->GetLongField(jthis, JavaDOMGlobals::nodePtrFID);
if (!pi) {
if (!pi || !jdata) {
JavaDOMGlobals::ThrowException(env,
"ProcessingInstruction.setData: NULL pointer");
return;
}
const char* data = NULL;
jboolean iscopy = JNI_FALSE;
if (jdata) {
data = env->GetStringUTFChars(jdata, &iscopy);
if (!data) {
JavaDOMGlobals::ThrowException(env,
const char* data = env->GetStringUTFChars(jdata, &iscopy);
if (!data) {
JavaDOMGlobals::ThrowException(env,
"ProcessingInstruction.setData: GetStringUTFChars failed");
return;
}
return;
}
nsresult rv = pi->SetData(data);