Skip to content

Conversation

@chcg
Copy link
Contributor

@chcg chcg commented Oct 11, 2018

Issue #14 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
Copy link
Contributor Author

chcg commented Oct 11, 2018

@ffes What do you think about #16:

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.

@ffes ffes merged commit 14fb6d4 into ffes:master Jan 30, 2019
@ffes
Copy link
Owner

ffes commented Jan 30, 2019

Thanks for your contribution

@chcg chcg deleted the issue_14 branch December 11, 2020 22:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants