* [Edbrowse-dev] [PATCH] Initialize some stack-allocated variables.
@ 2011-03-27 12:50 Christopher Brannon
0 siblings, 0 replies; only message in thread
From: Christopher Brannon @ 2011-03-27 12:50 UTC (permalink / raw)
To: edbrowse-dev
The uninitialized nogo variable was being used in the test of an
if-statement. Code that assigns a value isn't guaranteed to execute
before nogo is tested.
I added some other initializations to runCommand as well,
though these aren't strictly necessary.
---
src/buffers.c | 12 ++++++------
1 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/src/buffers.c b/src/buffers.c
index 7710c2d..7382c13 100644
--- a/src/buffers.c
+++ b/src/buffers.c
@@ -3486,15 +3486,16 @@ readyUndo(void)
bool
runCommand(const char *line)
{
- int i, j, n, writeMode;
- struct ebWindow *w;
- void *ev; /* event variables */
- bool nogo, rc;
+ int i, j, n;
+ int writeMode = O_TRUNC;
+ struct ebWindow *w = NULL;
+ void *ev = NULL; /* event variables */
+ bool nogo = true, rc = true;
bool postSpace = false, didRange = false;
char first;
int cx = 0; /* numeric suffix as in s/x/y/3 or w2 */
int tagno;
- const char *s;
+ const char *s = NULL;
static char newline[MAXTTYLINE];
if(allocatedLine) {
@@ -3637,7 +3638,6 @@ runCommand(const char *line)
}
first = *line;
- writeMode = O_TRUNC;
if(cmd == 'w' && first == '+')
writeMode = O_APPEND, first = *++line;
--
1.7.3.4
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2011-03-27 13:04 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-03-27 12:50 [Edbrowse-dev] [PATCH] Initialize some stack-allocated variables Christopher Brannon
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).