[vlc-commits] [Git][videolan/vlc][master] json: Change `json_object_to_float` to prevent misaligned cast
Steve Lhomme (@robUx4)
gitlab at videolan.org
Fri Mar 13 10:42:34 UTC 2026
Steve Lhomme pushed to branch master at VideoLAN / VLC
Commits:
2b889203 by Gabriel Lafond-Thenaille at 2026-03-13T10:23:34+00:00
json: Change `json_object_to_float` to prevent misaligned cast
Remove the double casting to prevent a 4bytes aligned varriable to be
cast to double.
- - - - -
1 changed file:
- modules/misc/preparser_serializer/json/fromjson.c
Changes:
=====================================
modules/misc/preparser_serializer/json/fromjson.c
=====================================
@@ -296,8 +296,23 @@ static inline bool json_object_to_uint_sized(const struct json_object *obj,
json_object_to_number(obj, name, number, error, -DBL_MAX, DBL_MAX)
/* Ensure that the returned number is a float. */
-#define json_object_to_float(obj, name, number, error) \
- json_object_to_number(obj, name, (double *)(number), error, -FLT_MAX, FLT_MAX)
+static inline bool json_object_to_float(const struct json_object *obj,
+ const char *name, float *number,
+ bool *error)
+{
+
+ assert(obj != NULL);
+ assert(name != NULL);
+ assert(number != NULL);
+ assert(error != NULL);
+
+ double n = NAN;
+ json_object_to_number(obj, name, &n, error, -FLT_MAX, FLT_MAX);
+ if (!*error) {
+ *number = (float)n;
+ }
+ return *error;
+}
/* Get value in `obj` with the key `name` and check if it's a string or null.
*/
@@ -1455,7 +1470,6 @@ fromJSON_vlc_preparser_msg(struct serdes_sys *sys,
#undef json_array_integer_load
#undef json_array_boolean_load
#undef json_array_foreach_ref
-#undef json_object_to_float
#undef json_object_to_double
#undef json_object_to_int
#undef json_object_to_uint
View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/2b889203975b93d7368a6e8c986b2024d31b5285
--
View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/2b889203975b93d7368a6e8c986b2024d31b5285
You're receiving this email because of your account on code.videolan.org.
VideoLAN code repository instance
More information about the vlc-commits
mailing list