mirror of https://github.com/GNOME/gimp.git
libgimpconfig: fix conversion of negative int values in gimp_scanner_parse_float()
Negative int values were not correctly handled because value.v_int is unsigned causing a conversion to a large positive value. To fix this we cast it to gint64 first before making it negative.
This commit is contained in:
parent
6dae2c1d33
commit
71ad53ebcf
|
@ -594,22 +594,17 @@ gimp_scanner_parse_float (GimpScanner *scanner,
|
|||
}
|
||||
else if (g_scanner_peek_next_token (scanner) == G_TOKEN_INT)
|
||||
{
|
||||
/* use a temp value because for whatever reason writing
|
||||
/* v_int is unsigned so we need to cast to
|
||||
*
|
||||
* *dest = -scanner->value.v_int;
|
||||
*
|
||||
* fails.
|
||||
* gint64 first for negative values.
|
||||
*/
|
||||
gint64 int_value;
|
||||
|
||||
g_scanner_get_next_token (scanner);
|
||||
|
||||
if (negate)
|
||||
int_value = -scanner->value.v_int;
|
||||
*dest = - (gint64) scanner->value.v_int;
|
||||
else
|
||||
int_value = scanner->value.v_int;
|
||||
|
||||
*dest = int_value;
|
||||
*dest = scanner->value.v_int;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue