{"action":"created","issue":{"url":"https://api.github.com/repos/pljson/pljson/issues/15","labels_url":"https://api.github.com/repos/pljson/pljson/issues/15/labels{/name}","comments_url":"https://api.github.com/repos/pljson/pljson/issues/15/comments","events_url":"https://api.github.com/repos/pljson/pljson/issues/15/events","html_url":"https://github.com/pljson/pljson/issues/15","id":108596817,"number":15,"title":"Buffer Overflow with german umlauts","user":{"login":"kschlesselmann","id":3634869,"avatar_url":"https://avatars.githubusercontent.com/u/3634869?v=3","gravatar_id":"","url":"https://api.github.com/users/kschlesselmann","html_url":"https://github.com/kschlesselmann","followers_url":"https://api.github.com/users/kschlesselmann/followers","following_url":"https://api.github.com/users/kschlesselmann/following{/other_user}","gists_url":"https://api.github.com/users/kschlesselmann/gists{/gist_id}","starred_url":"https://api.github.com/users/kschlesselmann/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kschlesselmann/subscriptions","organizations_url":"https://api.github.com/users/kschlesselmann/orgs","repos_url":"https://api.github.com/users/kschlesselmann/repos","events_url":"https://api.github.com/users/kschlesselmann/events{/privacy}","received_events_url":"https://api.github.com/users/kschlesselmann/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/pljson/pljson/labels/bug","name":"bug","color":"fc2929"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":5,"created_at":"2015-09-28T06:31:06Z","updated_at":"2015-09-28T17:03:34Z","closed_at":null,"body":"It seems that d233728e5af724e9f17d0890b04719e62d814dfd introduced escaping problems with special characters.\r\n\r\n    declare\r\n        tmp json := json();\r\n    begin\r\n        tmp.put('foo', 'bär');\r\n        tmp.print;\r\n    end;\r\n    /\r\nleads to\r\n> ORA-06502: PL/SQL: numeric or value error: character string buffer too small\r\n> ORA-06512: at \"TMP.JSON_PRINTER\", line 78\r\n> ORA-06512: at \"TMP.JSON_PRINTER\", line 252\r\n> ORA-06512: at \"TMP.JSON_PRINTER\", line 279\r\n> ORA-06512: at \"TMP.JSON_PRINTER\", line 297\r\n> ORA-06512: at \"TMP.JSON\", line 274\r\n> ORA-06512: at line 5\r\n> 06502. 00000 -  \"PL/SQL: numeric or value error%s\"\r\n> *Cause:    An arithmetic, numeric, string, conversion, or constraint error\r\n>            occurred. For example, this error occurs if an attempt is made to\r\n>            assign the value NULL to a variable declared NOT NULL, or if an\r\n>            attempt is made to assign an integer larger than 99 to a variable\r\n>            declared NUMBER(2).\r\n> *Action:   Change the data, how it is manipulated, or how it is declared so\r\n>            that values do not violate constraints.\r\n\r\nPrior versions generated\r\n\r\n    {\"foo\" : \"b\\u00FCr\"}\r\n\r\nThe problem seems to be that the `ä` doesn't fit into the `CHAR` in line\r\n\r\n    ch := substr(str, i, 1 ) ;\r\n\r\nany more. You can easily reproduce the issue with\r\n\r\n    declare\r\n        st varchar2(1024) := 'ä';\r\n        ch char;\r\n    begin\r\n        select substr(st, 1, 1) INTO ch FROM DUAL;\r\n        dbms_output.put_line(ch);\r\n    end;\r\n    /\r\n\r\nwhich leads to the same error."},"comment":{"url":"https://api.github.com/repos/pljson/pljson/issues/comments/143805328","html_url":"https://github.com/pljson/pljson/issues/15#issuecomment-143805328","issue_url":"https://api.github.com/repos/pljson/pljson/issues/15","id":143805328,"user":{"login":"csm101","id":5736859,"avatar_url":"https://avatars.githubusercontent.com/u/5736859?v=3","gravatar_id":"","url":"https://api.github.com/users/csm101","html_url":"https://github.com/csm101","followers_url":"https://api.github.com/users/csm101/followers","following_url":"https://api.github.com/users/csm101/following{/other_user}","gists_url":"https://api.github.com/users/csm101/gists{/gist_id}","starred_url":"https://api.github.com/users/csm101/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/csm101/subscriptions","organizations_url":"https://api.github.com/users/csm101/orgs","repos_url":"https://api.github.com/users/csm101/repos","events_url":"https://api.github.com/users/csm101/events{/privacy}","received_events_url":"https://api.github.com/users/csm101/received_events","type":"User","site_admin":false},"created_at":"2015-09-28T17:03:33Z","updated_at":"2015-09-28T17:03:33Z","body":"As side note: I think you are facing some kind of oracle bug: on old versions of oracle I experienced too weird things happening when trying to assign values to char(1) variables, l\r\n\r\nIn my case what was happening is that I had a char(1) field in the database, and it contained plain ASCII characters ('Y' or 'N'). Well: that version of oracle forced me to rewrite all the selects of such field as \"select substr(myfield,1,1) into char_var\", like it was insisting in padding the values being read with unneeded spaces. the bug disappeared when I upgraded the servers.\r\n\r\ncould you please try to change the declaration of that local variable from \"char(1)\" to \"varchar2(1)\" and see if it does the trick?"}}