mirror of
https://github.com/netsurf-browser/netsurf
synced 2024-12-19 02:32:44 +03:00
Fix possible dereference of NULL
The return of calloc was not being checked and could have lead to a NULL pointer dereference. This fixes coverity CID 1316337 Additionally the functions documentation comments were cleaned up.
This commit is contained in:
parent
c45afb6a29
commit
1ace8538d1
@ -235,13 +235,25 @@ void html_mouse_track(struct content *c, struct browser_window *bw,
|
|||||||
html_mouse_action(c, bw, mouse, x, y);
|
html_mouse_action(c, bw, mouse, x, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Helper for file gadgets to store their filename unencoded on the
|
/**
|
||||||
* dom node associated with the gadget.
|
* Helper for file gadgets to store their filename.
|
||||||
|
*
|
||||||
|
* Stores the filename unencoded on the dom node associated with the
|
||||||
|
* gadget.
|
||||||
*
|
*
|
||||||
* \todo Get rid of this crap eventually
|
* \todo Get rid of this crap eventually
|
||||||
|
*
|
||||||
|
* \param operation DOM operation
|
||||||
|
* \param key DOM node key being considerd
|
||||||
|
* \param _data The data assocated with the key
|
||||||
|
* \param src The source DOM node.
|
||||||
|
* \param dst The destination DOM node.
|
||||||
*/
|
*/
|
||||||
static void html__image_coords_dom_user_data_handler(dom_node_operation operation,
|
static void
|
||||||
dom_string *key, void *_data, struct dom_node *src,
|
html__image_coords_dom_user_data_handler(dom_node_operation operation,
|
||||||
|
dom_string *key,
|
||||||
|
void *_data,
|
||||||
|
struct dom_node *src,
|
||||||
struct dom_node *dst)
|
struct dom_node *dst)
|
||||||
{
|
{
|
||||||
struct image_input_coords *oldcoords, *coords = _data, *newcoords;
|
struct image_input_coords *oldcoords, *coords = _data, *newcoords;
|
||||||
@ -254,13 +266,20 @@ static void html__image_coords_dom_user_data_handler(dom_node_operation operatio
|
|||||||
switch (operation) {
|
switch (operation) {
|
||||||
case DOM_NODE_CLONED:
|
case DOM_NODE_CLONED:
|
||||||
newcoords = calloc(1, sizeof(*newcoords));
|
newcoords = calloc(1, sizeof(*newcoords));
|
||||||
|
if (newcoords != NULL) {
|
||||||
*newcoords = *coords;
|
*newcoords = *coords;
|
||||||
if (dom_node_set_user_data(dst,
|
if (dom_node_set_user_data(dst,
|
||||||
corestring_dom___ns_key_image_coords_node_data,
|
corestring_dom___ns_key_image_coords_node_data,
|
||||||
newcoords, html__image_coords_dom_user_data_handler,
|
newcoords,
|
||||||
|
html__image_coords_dom_user_data_handler,
|
||||||
&oldcoords) == DOM_NO_ERR) {
|
&oldcoords) == DOM_NO_ERR) {
|
||||||
free(oldcoords);
|
free(oldcoords);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case DOM_NODE_DELETED:
|
||||||
|
free(coords);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case DOM_NODE_RENAMED:
|
case DOM_NODE_RENAMED:
|
||||||
@ -268,9 +287,6 @@ static void html__image_coords_dom_user_data_handler(dom_node_operation operatio
|
|||||||
case DOM_NODE_ADOPTED:
|
case DOM_NODE_ADOPTED:
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case DOM_NODE_DELETED:
|
|
||||||
free(coords);
|
|
||||||
break;
|
|
||||||
default:
|
default:
|
||||||
LOG("User data operation not handled.");
|
LOG("User data operation not handled.");
|
||||||
assert(0);
|
assert(0);
|
||||||
|
Loading…
Reference in New Issue
Block a user