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,14 +235,26 @@ 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,
|
||||||
struct dom_node *dst)
|
dom_string *key,
|
||||||
|
void *_data,
|
||||||
|
struct dom_node *src,
|
||||||
|
struct dom_node *dst)
|
||||||
{
|
{
|
||||||
struct image_input_coords *oldcoords, *coords = _data, *newcoords;
|
struct image_input_coords *oldcoords, *coords = _data, *newcoords;
|
||||||
|
|
||||||
@ -254,23 +266,27 @@ 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));
|
||||||
*newcoords = *coords;
|
if (newcoords != NULL) {
|
||||||
if (dom_node_set_user_data(dst,
|
*newcoords = *coords;
|
||||||
corestring_dom___ns_key_image_coords_node_data,
|
if (dom_node_set_user_data(dst,
|
||||||
newcoords, html__image_coords_dom_user_data_handler,
|
corestring_dom___ns_key_image_coords_node_data,
|
||||||
&oldcoords) == DOM_NO_ERR) {
|
newcoords,
|
||||||
free(oldcoords);
|
html__image_coords_dom_user_data_handler,
|
||||||
|
&oldcoords) == DOM_NO_ERR) {
|
||||||
|
free(oldcoords);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case DOM_NODE_DELETED:
|
||||||
|
free(coords);
|
||||||
|
break;
|
||||||
|
|
||||||
case DOM_NODE_RENAMED:
|
case DOM_NODE_RENAMED:
|
||||||
case DOM_NODE_IMPORTED:
|
case DOM_NODE_IMPORTED:
|
||||||
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