Branch: refs/heads/master Author: Colomban Wendling ban@herbesfolles.org Committer: Colomban Wendling ban@herbesfolles.org Date: Sun, 08 Jul 2012 11:21:55 Commit: 29e7c7efae104586ecccb9b228e99506f2acd7b6 https://github.com/geany/geany-plugins/commit/29e7c7efae104586ecccb9b228e995...
Log Message: ----------- GeanyPG: Don't use C99 variable length arrays
Modified Paths: -------------- geanypg/src/helper_functions.c geanypg/src/key_selection_dialog.c
Modified: geanypg/src/helper_functions.c 11 files changed, 7 insertions(+), 4 deletions(-) =================================================================== @@ -159,22 +159,25 @@ void geanypg_load_buffer(gpgme_data_t * buffer)
void geanypg_write_file(FILE * file) { - unsigned bufsize = 2048; +#define BUFSIZE 2048 + unsigned long size; - char buffer[bufsize]; + char buffer[BUFSIZE] = {0}; GeanyDocument * doc = document_get_current(); if (abs(sci_get_selection_start(doc->editor->sci) - sci_get_selection_end(doc->editor->sci))) { /* replace selected text * clear selection, cursor should be at the end or beginneng of the selection */ scintilla_send_message(doc->editor->sci, SCI_REPLACESEL, 0, (sptr_t)""); - while ((size = fread(buffer, 1, bufsize, file))) + while ((size = fread(buffer, 1, BUFSIZE, file))) /* add at the cursor */ scintilla_send_message(doc->editor->sci, SCI_ADDTEXT, (uptr_t) size, (sptr_t) buffer); } else { /* replace complete document */ scintilla_send_message(doc->editor->sci, SCI_CLEARALL, 0, 0); - while ((size = fread(buffer, 1, bufsize, file))) + while ((size = fread(buffer, 1, BUFSIZE, file))) scintilla_send_message(doc->editor->sci, SCI_APPENDTEXT, (uptr_t) size, (sptr_t) buffer); } + +#undef BUFSIZE }
Modified: geanypg/src/key_selection_dialog.c 4 files changed, 2 insertions(+), 2 deletions(-) =================================================================== @@ -70,14 +70,14 @@ static GtkListStore * geanypg_makelist(gpgme_key_t * key_array, unsigned long nk { char * name = (key_array[idx]->uids && key_array[idx]->uids->name) ? key_array[idx]->uids->name : &empty_string; char * email = (key_array[idx]->uids && key_array[idx]->uids->email) ? key_array[idx]->uids->email : &empty_string; - char buffer[strlen(name) + strlen(email) + 7]; - sprintf(buffer, "%s <%s>", name, email); + gchar * buffer = g_strdup_printf("%s <%s>", name, email); gtk_list_store_append(list, &iter); gtk_list_store_set(list, &iter, TOGGLE_COLUMN, FALSE, RECIPIENT_COLUMN, buffer, KEYID_COLUMN, key_array[idx]->subkeys->keyid, -1); + g_free(buffer); } return list; }
@@ Diff output truncated at 100000 characters. @@
-------------- This E-Mail was brought to you by github_commit_mail.py (Source: TBD).
plugins-commits@lists.geany.org