3
Vote

Memory access error marshalling scope info

description

In DirectoryObjectPickerDialog.cs, the scope info is not marshalled correctly.
 
The pointer points to newly allocated memory, so there is no need to free existing object (the last parameter).
 
When true the pointer is freed, however usually the pointer will contain 0x00, i.e. null anyway. Sometimes, however, the allocated memory will contain other data and when this happens it is treated as a random pointer and usually generates an page access error.
 
The correct value should be False.
 
            Marshal.StructureToPtr(scopeInitInfo[index],
                (IntPtr)((int)refScopeInitInfo + index * Marshal.SizeOf(typeof(DSOP_SCOPE_INIT_INFO))),
                false);

comments