NetTalk Central

Author Topic: Nulls in String in a browse field cause "Index out of range" error.  (Read 2087 times)

Rob Kolanko

  • Sr. Member
  • ****
  • Posts: 253
    • View Profile
Hi Bruce,
If a string variable accidentally has NULL character(s) in it and the variable is displayed as string browse field, the Server program will crash with a  "Index out of range" error.
Through GPF reporter, I isolated that line that causes the error.
In NetWebServerWorker.AsciiToUtf method, there is a line :

if Ascii[val(p_text[x])]

- if p_text[x] is Null (chr(0)) this will generate a run time error.
 
I have put a check for the file variable that caused the problem in my application and it is the programmer's responsibility to pass a valid string. However, I believe that it is pertinent to have a index check in the AsciiToUtf method to handle nulls.  

Perhaps add this code prior to the above line:
    if p_text[x]=chr(0)
      p_text[x]=''
    END

Thanks
Rob
« Last Edit: July 08, 2013, 02:16:43 PM by Rob Kolanko »

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11239
    • View Profile
Re: Nulls in String in a browse field cause "Index out of range" error.
« Reply #1 on: July 08, 2013, 09:57:51 PM »
yes, I agree - done for 7.15

cheers
Bruce