Permalink
Browse files

Fix bug 3557458 -- when encrypting selected text a 0 byte gets added …

…to the text that's being encrypted
  • Loading branch information...
1 parent 1f44137 commit fe607cfa75950b2c9706b5585c60f8370d51a089 @alvesh88 alvesh88 committed with Aug 24, 2012
Showing with 6 additions and 3 deletions.
  1. +5 −0 geanypg/ChangeLog
  2. +1 −3 geanypg/src/helper_functions.c
View
@@ -1,3 +1,8 @@
+2012-08-24 Hans Alves <alves(dot)h88(at)gmail(dot)com>
+
+* Fixed bug 3557458 which caused a 0 byte to be added to the text
+ when encrypting a selection.
+
2012-06-04 Hans Alves <alves(dot)h88(at)gmail(dot)com>
* Fixed a bug that caused an error message to appear if one of the
@@ -137,7 +137,7 @@ void geanypg_load_buffer(gpgme_data_t * buffer)
unsigned long size = 0;
if (sci_has_selection(doc->editor->sci))
{
- size = scintilla_send_message(doc->editor->sci, SCI_GETSELTEXT, 0, 0);
+ size = scintilla_send_message(doc->editor->sci, SCI_GETSELTEXT, 0, 0) - 1;
data = (char *) malloc(size + 1);
scintilla_send_message(doc->editor->sci, SCI_GETSELTEXT, 0, (sptr_t)data);
gpgme_data_new_from_mem(buffer, data, size, 1);
@@ -157,7 +157,6 @@ void geanypg_load_buffer(gpgme_data_t * buffer)
void geanypg_write_file(FILE * file)
{
#define BUFSIZE 2048
-
unsigned long size;
char buffer[BUFSIZE] = {0};
GeanyDocument * doc = document_get_current();
@@ -177,6 +176,5 @@ void geanypg_write_file(FILE * file)
scintilla_send_message(doc->editor->sci, SCI_APPENDTEXT, (uptr_t) size, (sptr_t) buffer);
}
sci_end_undo_action(doc->editor->sci);
-
#undef BUFSIZE
}

0 comments on commit fe607cf

Please sign in to comment.