File tree Expand file tree Collapse file tree 4 files changed +19
-1
lines changed Expand file tree Collapse file tree 4 files changed +19
-1
lines changed Original file line number Diff line number Diff line change 11{
22 "name" : " libpg-query" ,
3- "version" : " 17.3.1 " ,
3+ "version" : " 17.3.3 " ,
44 "description" : " The real PostgreSQL query parser" ,
55 "homepage" : " https://github.com/launchql/libpg-query-node" ,
66 "main" : " ./wasm/index.cjs" ,
Original file line number Diff line number Diff line change @@ -62,6 +62,9 @@ function awaitInit<T extends (...args: any[]) => Promise<any>>(fn: T): T {
6262
6363function stringToPtr ( str : string ) : number {
6464 ensureLoaded ( ) ;
65+ if ( typeof str !== 'string' ) {
66+ throw new TypeError ( `Expected a string, got ${ typeof str } ` ) ;
67+ }
6568 const len = wasmModule . lengthBytesUTF8 ( str ) + 1 ;
6669 const ptr = wasmModule . _malloc ( len ) ;
6770 try {
@@ -75,6 +78,9 @@ function stringToPtr(str: string): number {
7578
7679function ptrToString ( ptr : number ) : string {
7780 ensureLoaded ( ) ;
81+ if ( typeof ptr !== 'number' ) {
82+ throw new TypeError ( `Expected a number, got ${ typeof ptr } ` ) ;
83+ }
7884 return wasmModule . UTF8ToString ( ptr ) ;
7985}
8086
Original file line number Diff line number Diff line change @@ -51,6 +51,9 @@ function awaitInit(fn) {
5151}
5252function stringToPtr ( str ) {
5353 ensureLoaded ( ) ;
54+ if ( typeof str !== 'string' ) {
55+ throw new TypeError ( `Expected a string, got ${ typeof str } ` ) ;
56+ }
5457 const len = wasmModule . lengthBytesUTF8 ( str ) + 1 ;
5558 const ptr = wasmModule . _malloc ( len ) ;
5659 try {
@@ -64,6 +67,9 @@ function stringToPtr(str) {
6467}
6568function ptrToString ( ptr ) {
6669 ensureLoaded ( ) ;
70+ if ( typeof ptr !== 'number' ) {
71+ throw new TypeError ( `Expected a number, got ${ typeof ptr } ` ) ;
72+ }
6773 return wasmModule . UTF8ToString ( ptr ) ;
6874}
6975exports . parse = awaitInit ( async ( query ) => {
Original file line number Diff line number Diff line change @@ -24,6 +24,9 @@ function awaitInit(fn) {
2424}
2525function stringToPtr ( str ) {
2626 ensureLoaded ( ) ;
27+ if ( typeof str !== 'string' ) {
28+ throw new TypeError ( `Expected a string, got ${ typeof str } ` ) ;
29+ }
2730 const len = wasmModule . lengthBytesUTF8 ( str ) + 1 ;
2831 const ptr = wasmModule . _malloc ( len ) ;
2932 try {
@@ -37,6 +40,9 @@ function stringToPtr(str) {
3740}
3841function ptrToString ( ptr ) {
3942 ensureLoaded ( ) ;
43+ if ( typeof ptr !== 'number' ) {
44+ throw new TypeError ( `Expected a number, got ${ typeof ptr } ` ) ;
45+ }
4046 return wasmModule . UTF8ToString ( ptr ) ;
4147}
4248export const parse = awaitInit ( async ( query ) => {
You can’t perform that action at this time.
0 commit comments