@@ -26,7 +26,7 @@ public static ActionResult CheckAppPath(Session session)
2626 //return failure if the app path is the program files directory
2727 string progFilesDir = Environment . GetFolderPath ( Environment . SpecialFolder . ProgramFiles ) ;
2828 string progFiles86Dir = Environment . GetFolderPath ( Environment . SpecialFolder . ProgramFilesX86 ) ;
29-
29+
3030 //On 32bit XP machines ProgramFilesX86 will return an empty string.
3131 if ( String . IsNullOrEmpty ( progFiles86Dir ) )
3232 progFiles86Dir = progFilesDir ;
@@ -86,6 +86,13 @@ public static ActionResult VerifyDataDirPath(Session session)
8686 session . Log ( "Begin VerifyDataPath in custom action dll" ) ;
8787 string registryKey = session [ "REGISTRYDATAKEY" ] ;
8888 string valueName = session [ "REGISTRYDATAVALUENAME" ] ;
89+ if ( string . IsNullOrWhiteSpace ( registryKey ) || string . IsNullOrWhiteSpace ( valueName ) )
90+ {
91+ session . Log ( "VerifyDataPath: REGISTRYDATAKEY or REGISTRYDATAVALUENAME is missing." ) ;
92+ session [ "REGDATAFOLDER" ] = null ;
93+ session [ "DATAFOLDERFOUND" ] = "NotFound" ;
94+ return ActionResult . Success ;
95+ }
8996 string regDataPath = GetDataDirFromRegistry ( registryKey , valueName , session ) ;
9097 if ( string . IsNullOrEmpty ( regDataPath ) )
9198 {
@@ -95,7 +102,7 @@ public static ActionResult VerifyDataDirPath(Session session)
95102 }
96103
97104 session [ "REGDATAFOLDER" ] = regDataPath ;
98-
105+
99106 if ( Directory . Exists ( regDataPath ) && Directory . GetFiles ( regDataPath ) . Length > 0 )
100107 session [ "DATAFOLDERFOUND" ] = "AlreadyExisting" ;
101108 else
@@ -213,16 +220,27 @@ public static ActionResult LookForInstalledFonts(Session session)
213220
214221 private static string GetDataDirFromRegistry ( string path , string valueName , Session session )
215222 {
223+ if ( string . IsNullOrWhiteSpace ( path ) || string . IsNullOrWhiteSpace ( valueName ) )
224+ return null ;
225+
216226 string dataPathKey = "HKEY_LOCAL_MACHINE\\ SOFTWARE\\ " + path ;
217227 string dataPathKeyWow = "HKEY_LOCAL_MACHINE\\ SOFTWARE\\ Wow6432Node\\ " + path ;
218228
219229 string projPath = "" ;
220230 try
221231 {
222232 if ( RegistryU . KeyExists ( dataPathKey ) )
223- projPath = RegistryU . GetKey ( "HKLM" , "SOFTWARE\\ " + path ) . GetValue ( valueName ) . ToString ( ) ;
233+ {
234+ var value = RegistryU . GetKey ( "HKLM" , "SOFTWARE\\ " + path ) ? . GetValue ( valueName ) ;
235+ if ( value != null )
236+ projPath = value . ToString ( ) ;
237+ }
224238 if ( RegistryU . KeyExists ( dataPathKeyWow ) )
225- projPath = RegistryU . GetKey ( "HKLM" , "SOFTWARE\\ Wow6432Node\\ " + path ) . GetValue ( valueName ) . ToString ( ) ;
239+ {
240+ var value = RegistryU . GetKey ( "HKLM" , "SOFTWARE\\ Wow6432Node\\ " + path ) ? . GetValue ( valueName ) ;
241+ if ( value != null )
242+ projPath = value . ToString ( ) ;
243+ }
226244 }
227245 catch ( Exception ex )
228246 {
0 commit comments