Skip to content

Commit

Permalink
[aot] Fix a memory leak related to constraint allocation/deallocation. (
Browse files Browse the repository at this point in the history
#4880)

* [jit] Make a copy of the constraint in mini_get_shared_gparam().

* [aot] Free the temporary gshared constraint in decode_class_ref().
  • Loading branch information
vkargov authored and luhenry committed May 18, 2017
1 parent 20ab5bf commit 1009c92
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 0 deletions.
1 change: 1 addition & 0 deletions mono/mini/aot-runtime.c
Expand Up @@ -505,6 +505,7 @@ decode_klass_ref (MonoAotModule *module, guint8 *buf, guint8 **endbuf, MonoError
return NULL;

t = mini_get_shared_gparam (&par_klass->byval_arg, gshared_constraint);
mono_metadata_free_type (gshared_constraint);
klass = mono_class_from_mono_type (t);
} else {
int type = decode_value (p, &p);
Expand Down
1 change: 1 addition & 0 deletions mono/mini/mini-generic-sharing.c
Expand Up @@ -3498,6 +3498,7 @@ mini_get_shared_gparam (MonoType *t, MonoType *constraint)
copy = (MonoGSharedGenericParam *)mono_image_alloc0 (image, sizeof (MonoGSharedGenericParam));
memcpy (&copy->param, par, sizeof (MonoGenericParamFull));
copy->param.info.pklass = NULL;
constraint = mono_metadata_type_dup (image, constraint);
name = get_shared_gparam_name (constraint->type, ((MonoGenericParamFull*)copy)->info.name);
copy->param.info.name = mono_image_strdup (image, name);
g_free (name);
Expand Down

0 comments on commit 1009c92

Please sign in to comment.