mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-01-11 23:16:14 +01:00
girnode: Improve int types in GIIrNodeVFunc
`GIIrNodeVFunc` is built dynamically at runtime (rather than being mmapped from disk), so its types can accurately reflect their runtime semantics, rather than an on-disk format. As part of this, switch from `atoi()` to `g_ascii_string_to_unsigned()` for parsing the relevant fields from a GIR XML file. This means we now get error handling for invalid integers. Signed-off-by: Philip Withnall <pwithnall@gnome.org> Helps: #3155
This commit is contained in:
parent
468b926c2b
commit
48d9f356c3
@ -243,7 +243,7 @@ struct _GIIrNodeVFunc
|
||||
GList *parameters; /* (element-type GIIrNode) (owned) */
|
||||
GIIrNodeParam *result; /* (owned) */
|
||||
|
||||
int offset;
|
||||
size_t offset;
|
||||
};
|
||||
|
||||
struct _GIIrNodeField
|
||||
|
@ -2561,6 +2561,7 @@ start_vfunc (GMarkupParseContext *context,
|
||||
const char *throws;
|
||||
GIIrNodeInterface *iface;
|
||||
GIIrNodeVFunc *vfunc;
|
||||
guint64 parsed_offset;
|
||||
|
||||
if (!(strcmp (element_name, "virtual-method") == 0 &&
|
||||
(ctx->state == STATE_CLASS ||
|
||||
@ -2620,10 +2621,15 @@ start_vfunc (GMarkupParseContext *context,
|
||||
else
|
||||
vfunc->throws = FALSE;
|
||||
|
||||
if (offset)
|
||||
vfunc->offset = atoi (offset);
|
||||
else
|
||||
if (offset == NULL)
|
||||
vfunc->offset = 0xFFFF;
|
||||
else if (g_ascii_string_to_unsigned (offset, 10, 0, G_MAXSIZE, &parsed_offset, error))
|
||||
vfunc->offset = parsed_offset;
|
||||
else
|
||||
{
|
||||
gi_ir_node_free ((GIIrNode *) vfunc);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
vfunc->invoker = g_strdup (invoker);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user