New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Creating Snippet from Selection crashes Notepad++ #14

Open
plazio11772 opened this Issue Dec 30, 2017 · 5 comments

Comments

Projects
None yet
5 participants
@plazio11772

plazio11772 commented Dec 30, 2017

When using the user interface to create snippets:

  1. Select text in NPP
  2. Right click in snippet library
  3. Select "Add from Selection" from context menu
  4. Edit snippet in Edit Snippet dialog box (this dialog box may contain foreign characters not selected in NPP document)
  5. Notepad++ then crashes
  6. When Notepad++ is reopened the snippet has be created

If the selection in the Notepad++ document is copied to the clipboard the process works if "Add from Clipboard" is selected the process works as expected.

Notepad++ Version 7.5.3 (64 bit)
NPPSnippets Version 1.4.0, released on 24-May-2017

@SchefferKD

This comment has been minimized.

Show comment
Hide comment
@SchefferKD

SchefferKD Jan 10, 2018

I can confirm this issue on the 32bit Version:

Notepad++ Version 7.5.3 (32 bit)
NPPSnippets Version 1.4.0, released on 24-May-2017

SchefferKD commented Jan 10, 2018

I can confirm this issue on the 32bit Version:

Notepad++ Version 7.5.3 (32 bit)
NPPSnippets Version 1.4.0, released on 24-May-2017

@jbostoen

This comment has been minimized.

Show comment
Hide comment
@jbostoen

jbostoen Apr 6, 2018

Even having this issue on simply creating a new empty snippet (name: test, type: XML, nothing else)

Notepad++ v7.5.6 (32 bit)
NPPSnippets version 1.4.0

jbostoen commented Apr 6, 2018

Even having this issue on simply creating a new empty snippet (name: test, type: XML, nothing else)

Notepad++ v7.5.6 (32 bit)
NPPSnippets version 1.4.0

@RobU23

This comment has been minimized.

Show comment
Hide comment
@RobU23

RobU23 May 6, 2018

Confirm crash creating new from selection. NPP 7.5.6 64bit, Snippets 1.4.0

RobU23 commented May 6, 2018

Confirm crash creating new from selection. NPP 7.5.6 64bit, Snippets 1.4.0

@chcg

This comment has been minimized.

Show comment
Hide comment
@chcg

chcg Aug 6, 2018

Callstack for the problem of adding a new entry with name "test" and empty "before cursor" entry:

 	KernelBase.dll!RaiseException�()	Unbekannt
 	[Externer Code]	
>	NppSnippets.dll!SqliteStatement::SaveRecord() Zeile 269	C++
 	NppSnippets.dll!Snippet::SaveToDB(bool autoOpen) Zeile 247	C++
 	NppSnippets.dll!OnOK(HWND__ * hDlg) Zeile 110	C++
 	NppSnippets.dll!DlgProc(HWND__ * hDlg, unsigned int message, unsigned __int64 wParam, __int64 lParam) Zeile 247	C++
 	[Externer Code]	
 	NppSnippets.dll!ShowEditSnippetDlg(Snippet * pSnippet) Zeile 280	C++
 	NppSnippets.dll!OnSnippetAdd(HWND__ * hWnd) Zeile 619	C++
 	NppSnippets.dll!OnCommand(HWND__ * hWnd, int ResID, int msg) Zeile 1108	C++
 	NppSnippets.dll!DlgProcedure(HWND__ * hWnd, unsigned int message, unsigned __int64 wParam, __int64 lParam) Zeile 1242	C++
 	[Externer Code]	
 	notepad++.exe!WinMain(HINSTANCE__ * hInstance, HINSTANCE__ * __formal, char * __formal, int __formal) Zeile 566	C++
 	[Externer Code]	

this is caused by sql table definition for snippets:

	BeforeSelection TEXT NOT NULL,

and SqliteStatement::Bind(int col, const WCHAR* val)

	else if (wcslen(val) == 0)
	{
		res = sqlite3_bind_null(_stmt, col);
	}

, which sets empty input to null.

chcg commented Aug 6, 2018

Callstack for the problem of adding a new entry with name "test" and empty "before cursor" entry:

 	KernelBase.dll!RaiseException�()	Unbekannt
 	[Externer Code]	
>	NppSnippets.dll!SqliteStatement::SaveRecord() Zeile 269	C++
 	NppSnippets.dll!Snippet::SaveToDB(bool autoOpen) Zeile 247	C++
 	NppSnippets.dll!OnOK(HWND__ * hDlg) Zeile 110	C++
 	NppSnippets.dll!DlgProc(HWND__ * hDlg, unsigned int message, unsigned __int64 wParam, __int64 lParam) Zeile 247	C++
 	[Externer Code]	
 	NppSnippets.dll!ShowEditSnippetDlg(Snippet * pSnippet) Zeile 280	C++
 	NppSnippets.dll!OnSnippetAdd(HWND__ * hWnd) Zeile 619	C++
 	NppSnippets.dll!OnCommand(HWND__ * hWnd, int ResID, int msg) Zeile 1108	C++
 	NppSnippets.dll!DlgProcedure(HWND__ * hWnd, unsigned int message, unsigned __int64 wParam, __int64 lParam) Zeile 1242	C++
 	[Externer Code]	
 	notepad++.exe!WinMain(HINSTANCE__ * hInstance, HINSTANCE__ * __formal, char * __formal, int __formal) Zeile 566	C++
 	[Externer Code]	

this is caused by sql table definition for snippets:

	BeforeSelection TEXT NOT NULL,

and SqliteStatement::Bind(int col, const WCHAR* val)

	else if (wcslen(val) == 0)
	{
		res = sqlite3_bind_null(_stmt, col);
	}

, which sets empty input to null.

@chcg

This comment has been minimized.

Show comment
Hide comment
@chcg

chcg Oct 11, 2018

Issue with selections is caused by a buffer overrun issue in:

Snippet::SetBeforeSelection()

with the handling of MultiByteToWideChar (https://docs.microsoft.com/en-us/windows/desktop/api/stringapiset/nf-stringapiset-multibytetowidechar) not using size of chars correctly.

chcg commented Oct 11, 2018

Issue with selections is caused by a buffer overrun issue in:

Snippet::SetBeforeSelection()

with the handling of MultiByteToWideChar (https://docs.microsoft.com/en-us/windows/desktop/api/stringapiset/nf-stringapiset-multibytetowidechar) not using size of chars correctly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment