]> git.tuebingen.mpg.de Git - paraslash.git/blobdiff - mp.c
aft: Avoid invalid read.
[paraslash.git] / mp.c
diff --git a/mp.c b/mp.c
index 3c84a05484cb38c15ba681c14c41cc37bb7cd932..56c16e31d7baf64fbf7c415b015b3de2967b6a38 100644 (file)
--- a/mp.c
+++ b/mp.c
@@ -6,10 +6,10 @@
  * This file contains the public and the private API of the flex/bison based
  * mood parser.
  *
  * This file contains the public and the private API of the flex/bison based
  * mood parser.
  *
- * The public API (at the bottom of the file) allows to parse the same mood
+ * The public API (at the bottom of the file) allows parsing the same mood
  * definition many times in an efficient manner.
  *
  * definition many times in an efficient manner.
  *
- * The first function to all is \ref mp_init(), which analyzes the given mood
+ * The first function to call is \ref mp_init(), which analyzes the given mood
  * definition syntactically. It returns the abstract syntax tree of the mood
  * definition and pre-compiles all regular expression patterns to make later
  * pattern matching efficient.
  * definition syntactically. It returns the abstract syntax tree of the mood
  * definition and pre-compiles all regular expression patterns to make later
  * pattern matching efficient.
@@ -61,8 +61,8 @@ struct mp_context {
  *
  * This function turns a generalized C99 string literal like "xyz\n" into a C
  * string (containing the three characters 'x', 'y' and 'z', followed by a
  *
  * This function turns a generalized C99 string literal like "xyz\n" into a C
  * string (containing the three characters 'x', 'y' and 'z', followed by a
- * newline character and the terminating zero byte). The function allows to
- * specify different quote characters so that, for example, regular expression
+ * newline character and the terminating zero byte). The function receives
+ * quote characters as an argument so that, for example, regular expression
  * patterns enclosed in '/' can be parsed as well. To parse a proper string
  * literal, one has to pass two double quotes as the second argument.
  *
  * patterns enclosed in '/' can be parsed as well. To parse a proper string
  * literal, one has to pass two double quotes as the second argument.
  *
@@ -491,10 +491,10 @@ int mp_init(const char *definition, int nbytes, struct mp_context **result,
        struct mp_context *ctx;
        struct yy_buffer_state *buffer_state;
 
        struct mp_context *ctx;
        struct yy_buffer_state *buffer_state;
 
+       *result = NULL;
        if (!definition || nbytes == 0) { /* dummy mood */
                if (errmsg)
                        *errmsg = NULL;
        if (!definition || nbytes == 0) { /* dummy mood */
                if (errmsg)
                        *errmsg = NULL;
-               *result = NULL;
                return 0;
        }
        ctx = para_calloc(sizeof(*ctx));
                return 0;
        }
        ctx = para_calloc(sizeof(*ctx));