mirror of
https://github.com/netsurf-browser/netsurf
synced 2025-01-03 09:44:24 +03:00
safely deal with NULL strings
This commit is contained in:
parent
c5fb16d56d
commit
e36b8f6579
@ -181,6 +181,8 @@ operation createTextNode %{
|
|||||||
dom_exception exc;
|
dom_exception exc;
|
||||||
dom_text *text;
|
dom_text *text;
|
||||||
|
|
||||||
|
if (data != NULL) {
|
||||||
|
|
||||||
JSLOG("Creating text node for string \"%s\"", data);
|
JSLOG("Creating text node for string \"%s\"", data);
|
||||||
exc = dom_string_create((unsigned char*)data, data_len, &data_dom);
|
exc = dom_string_create((unsigned char*)data, data_len, &data_dom);
|
||||||
if (exc != DOM_NO_ERR) {
|
if (exc != DOM_NO_ERR) {
|
||||||
@ -194,6 +196,7 @@ operation createTextNode %{
|
|||||||
}
|
}
|
||||||
|
|
||||||
jsret = jsapi_new_Text(cx, NULL, NULL, text, private->htmlc);
|
jsret = jsapi_new_Text(cx, NULL, NULL, text, private->htmlc);
|
||||||
|
}
|
||||||
|
|
||||||
JSLOG("returning jsobject %p",jsret);
|
JSLOG("returning jsobject %p",jsret);
|
||||||
|
|
||||||
@ -205,6 +208,7 @@ operation createElement %{
|
|||||||
dom_exception exc;
|
dom_exception exc;
|
||||||
dom_element *element;
|
dom_element *element;
|
||||||
|
|
||||||
|
if (localName != NULL) {
|
||||||
JSLOG("Creating text node for string \"%s\"", localName);
|
JSLOG("Creating text node for string \"%s\"", localName);
|
||||||
exc = dom_string_create((unsigned char*)localName, localName_len, &localName_dom);
|
exc = dom_string_create((unsigned char*)localName, localName_len, &localName_dom);
|
||||||
if (exc != DOM_NO_ERR) {
|
if (exc != DOM_NO_ERR) {
|
||||||
@ -218,6 +222,7 @@ operation createElement %{
|
|||||||
}
|
}
|
||||||
|
|
||||||
jsret = jsapi_new_HTMLElement(cx, NULL, NULL, element, private->htmlc);
|
jsret = jsapi_new_HTMLElement(cx, NULL, NULL, element, private->htmlc);
|
||||||
|
}
|
||||||
|
|
||||||
JSLOG("returning jsobject %p",jsret);
|
JSLOG("returning jsobject %p",jsret);
|
||||||
|
|
||||||
|
@ -15,6 +15,12 @@ function output(x,y) {
|
|||||||
}
|
}
|
||||||
for(var key in Node){
|
for(var key in Node){
|
||||||
output(key, Node[key]);
|
output(key, Node[key]);
|
||||||
|
}
|
||||||
|
|
||||||
|
document.body.appendChild(document.createElement('hr'));
|
||||||
|
|
||||||
|
for(var key in document.body){
|
||||||
|
output(key, document.body[key]);
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
|
Loading…
Reference in New Issue
Block a user