Issue #252: User input checks - raise an error when the method parameter does not fit the requirements jv
authorPatrik Svestka <patrik.svestka@gmail.com>
Thu, 31 Jan 2019 15:28:43 +0100
branchjv
changeset 23766 14192e6eeae8
parent 23765 ecd8104acb9a
child 23767 c0e32a3e2ca0
Issue #252: User input checks - raise an error when the method parameter does not fit the requirements - valueTypeAndSize: checking if nameString is a string if not, raise an error - deleteValueNamed: checking if nameString is a string if not, raise an error - deleteSubKeyNamed:flags: checking if nameString is a string if not, raise an error - subKeyNamed:flags:createIfAbsent: checking if subKeyString is a string if not, raise an error - valueNamed:put:unexpandedReferences: checking if nameString is a string if not, raise an error
Win32OperatingSystem.st
--- a/Win32OperatingSystem.st	Thu Jan 31 14:10:54 2019 +0100
+++ b/Win32OperatingSystem.st	Thu Jan 31 15:28:43 2019 +0100
@@ -15960,6 +15960,10 @@
 
     windowsRegistryTable := Dictionary new.
 
+    "/ checking user input
+    nameString isString ifFalse:[
+        self error: 'nameString is not a string!!'
+    ].
     "/ adding terminating null into empty string
     nameString notNil ifTrue:[
         nameUtf16Z := nameString isEmpty ifTrue:[(nameString, (Character codePoint: 0)) asUnicode16String] "/ needed for defaultValue
@@ -16123,6 +16127,10 @@
 
     |subKeyStringUtf16Z errorNumber|
 
+    "/ checking user input
+    subKeyString isString ifFalse:[
+        self error: 'subKeyString is not a string!!'
+    ].
     subKeyStringUtf16Z := subKeyString asUnicode16StringZ.
 
 %{
@@ -16554,6 +16562,10 @@
 
     |subKeyStringUtf16Z newEntry subHandle errorNumber disposition|
 
+    "/ checking user input
+    subKeyString isString ifFalse:[
+        self error: 'subKeyString is not a string!!'
+    ].
     subKeyStringUtf16Z := subKeyString asUnicode16StringZ.
 
 %{
@@ -16684,6 +16696,10 @@
 
     |nameUtf16Z errorNumber|
 
+    "/ checking user input
+    nameString isString ifFalse:[
+        self error: 'nameString is not a string!!'
+    ].
     "/ adding terminating null into empty string
     nameString notNil ifTrue:[
         nameUtf16Z := nameString isEmpty ifTrue:[(nameString, (Character codePoint: 0)) asUnicode16String] "/ needed for defaultValue
@@ -16814,7 +16830,6 @@
     nameString isString ifFalse:[
         self error: 'nameString is not a string!!'
     ].
-
     "/ adding terminating null into empty string
     nameString notNil ifTrue:[
         nameString isEmpty ifTrue:[nameUtf16Z := (nameString, (Character codePoint: 0)) asUnicode16String] "/ needed for defaultValue
@@ -17096,9 +17111,12 @@
     Null-terminated string that contains unexpanded references to environment variables (for example, ""%PATH%""). It will be a Unicode or ANSI string, 
     depending on whether you use the Unicode or ANSI functions.
     "
-
     |nameUtf16Z dataUtf16Z stringArray errorNumber|
-
+    
+    "/ checking user input
+    nameString isString ifFalse:[
+        self error: 'nameString is not a string!!'
+    ].
     "/ nameString asUnicodeString and null terminated
     nameString notNil ifTrue:[
         nameUtf16Z := nameString isEmpty ifTrue:[(nameString, (Character codePoint: 0)) asUnicode16String] "/ needed for defaultValue: