Skip to content

gi: Avoid infinite recursion when converting GValues

Florian Müllner requested to merge fmuellner/gjs:fix-infinite-recursion into master

gjs_value_to_g_value() special-cases GValues of type G_TYPE_VALUE by calling itself with an untyped "nested" GValue. As that nested GValue is untyped, the function will guess the type from the javascript value and set the GValue accordingly.

This works with one notable exception: If the javascript value itself holds a GValue, the guessed GType will be G_TYPE_VALUE again, and the same code path that calls gjs_value_to_g_value() will be called again ... and again ... and again ...

Avoid that infinite recursion by setting the original GValue directly if the javascript value already holds a GValue.

Merge request reports