* Sebastien Pouliot <sebastien@ximian.com>
*
* Copyright 2004-2009 Novell, Inc (http://www.novell.com)
+ * Licensed under the MIT license. See LICENSE file in the project root for full license information.
*/
#ifdef HAVE_CONFIG_H
if (uniname)
g_free (uniname);
- mono_error_raise_exception (&error);
+ mono_error_set_pending_exception (&error);
return result;
}
MonoArray*
ves_icall_System_Security_Principal_WindowsIdentity_GetRoles (gpointer token)
{
+ MonoError error;
MonoArray *array = NULL;
MonoDomain *domain = mono_domain_get ();
#ifdef HOST_WIN32
int i=0;
int num = tg->GroupCount;
- array = mono_array_new (domain, mono_get_string_class (), num);
+ array = mono_array_new_checked (domain, mono_get_string_class (), num, &error);
+ if (mono_error_set_pending_exception (&error)) {
+ g_free (tg);
+ return NULL;
+ }
for (i=0; i < num; i++) {
gint32 size = 0;
gunichar2 *uniname = GetSidName (NULL, tg->Groups [i].Sid, &size);
if (uniname) {
- MonoError error;
MonoString *str = mono_string_new_utf16_checked (domain, uniname, size, &error);
- mono_error_raise_exception (&error);
+ if (!is_ok (&error)) {
+ g_free (uniname);
+ g_free (tg);
+ mono_error_set_pending_exception (&error);
+ return NULL;
+ }
mono_array_setref (array, i, str);
g_free (uniname);
}
#endif
if (!array) {
/* return empty array of string, i.e. string [0] */
- array = mono_array_new (domain, mono_get_string_class (), 0);
+ array = mono_array_new_checked (domain, mono_get_string_class (), 0, &error);
+ mono_error_set_pending_exception (&error);
}
return array;
}
void
ves_icall_System_Security_SecureString_DecryptInternal (MonoArray *data, MonoObject *scope)
{
- invoke_protected_memory_method (data, scope, FALSE);
+ MonoError error;
+ invoke_protected_memory_method (data, scope, FALSE, &error);
+ mono_error_set_pending_exception (&error);
}
void
ves_icall_System_Security_SecureString_EncryptInternal (MonoArray* data, MonoObject *scope)
{
- invoke_protected_memory_method (data, scope, TRUE);
+ MonoError error;
+ invoke_protected_memory_method (data, scope, TRUE, &error);
+ mono_error_set_pending_exception (&error);
}
-void invoke_protected_memory_method (MonoArray *data, MonoObject *scope, gboolean encrypt)
+void invoke_protected_memory_method (MonoArray *data, MonoObject *scope, gboolean encrypt, MonoError *error)
{
- MonoError error;
MonoClass *klass;
MonoMethod *method;
void *params [2];
+ mono_error_init (error);
+
if (system_security_assembly == NULL) {
system_security_assembly = mono_image_loaded ("System.Security");
if (!system_security_assembly) {
params [0] = data;
params [1] = scope; /* MemoryProtectionScope.SameProcess */
- mono_runtime_invoke_checked (method, NULL, params, &error);
- mono_error_raise_exception (&error); /* FIXME don't raise here */
+ mono_runtime_invoke_checked (method, NULL, params, error);
}