diff options
author | Sergei Golubchik <serg@mariadb.org> | 2014-12-02 22:25:16 +0100 |
---|---|---|
committer | Sergei Golubchik <serg@mariadb.org> | 2014-12-02 22:25:16 +0100 |
commit | 853077ad7e81be1ade20b4beab1b95d5766d87b1 (patch) | |
tree | 4c158691947ba7beb4577f26b160f243eabf39ef /pcre/pcregrep.c | |
parent | bf3b4a23f75de50e0f1ab4a562e5801dabc7305b (diff) | |
parent | 2b5db1d5bcd7b46b654d59a07fc119ef6a6b8651 (diff) | |
download | mariadb-git-853077ad7e81be1ade20b4beab1b95d5766d87b1.tar.gz |
Merge branch '10.0' into bb-10.1-merge
Conflicts:
.bzrignore
VERSION
cmake/plugin.cmake
debian/dist/Debian/control
debian/dist/Ubuntu/control
mysql-test/r/join_outer.result
mysql-test/r/join_outer_jcl6.result
mysql-test/r/null.result
mysql-test/r/old-mode.result
mysql-test/r/union.result
mysql-test/t/join_outer.test
mysql-test/t/null.test
mysql-test/t/old-mode.test
mysql-test/t/union.test
packaging/rpm-oel/mysql.spec.in
scripts/mysql_config.sh
sql/ha_ndbcluster.cc
sql/ha_ndbcluster_binlog.cc
sql/ha_ndbcluster_cond.cc
sql/item_cmpfunc.h
sql/lock.cc
sql/sql_select.cc
sql/sql_show.cc
sql/sql_update.cc
sql/sql_yacc.yy
storage/innobase/buf/buf0flu.cc
storage/innobase/fil/fil0fil.cc
storage/innobase/include/srv0srv.h
storage/innobase/lock/lock0lock.cc
storage/tokudb/CMakeLists.txt
storage/xtradb/buf/buf0flu.cc
storage/xtradb/fil/fil0fil.cc
storage/xtradb/include/srv0srv.h
storage/xtradb/lock/lock0lock.cc
support-files/mysql.spec.sh
Diffstat (limited to 'pcre/pcregrep.c')
-rw-r--r-- | pcre/pcregrep.c | 29 |
1 files changed, 19 insertions, 10 deletions
diff --git a/pcre/pcregrep.c b/pcre/pcregrep.c index 3e8d05dc8ad..4f7fa38491a 100644 --- a/pcre/pcregrep.c +++ b/pcre/pcregrep.c @@ -455,7 +455,7 @@ Arguments: s pattern string to add after if not NULL points to item to insert after -Returns: new pattern block +Returns: new pattern block or NULL on error */ static patstr * @@ -471,6 +471,7 @@ if (strlen(s) > MAXPATLEN) { fprintf(stderr, "pcregrep: pattern is too long (limit is %d bytes)\n", MAXPATLEN); + free(p); return NULL; } p->next = NULL; @@ -2549,7 +2550,11 @@ while (fgets(buffer, PATBUFSIZE, f) != NULL) afterwards, as a precaution against any later code trying to use it. */ *patlastptr = add_pattern(buffer, *patlastptr); - if (*patlastptr == NULL) return FALSE; + if (*patlastptr == NULL) + { + if (f != stdin) fclose(f); + return FALSE; + } if (*patptr == NULL) *patptr = *patlastptr; /* This loop is needed because compiling a "pattern" when -F is set may add @@ -2561,7 +2566,10 @@ while (fgets(buffer, PATBUFSIZE, f) != NULL) { if (!compile_pattern(*patlastptr, pcre_options, popts, TRUE, filename, linenumber)) + { + if (f != stdin) fclose(f); return FALSE; + } (*patlastptr)->string = NULL; /* Insurance */ if ((*patlastptr)->next == NULL) break; *patlastptr = (*patlastptr)->next; @@ -2962,8 +2970,8 @@ if (locale == NULL) locale_from = "LC_CTYPE"; } -/* If a locale has been provided, set it, and generate the tables the PCRE -needs. Otherwise, pcretables==NULL, which causes the use of default tables. */ +/* If a locale is set, use it to generate the tables the PCRE needs. Otherwise, +pcretables==NULL, which causes the use of default tables. */ if (locale != NULL) { @@ -2971,7 +2979,7 @@ if (locale != NULL) { fprintf(stderr, "pcregrep: Failed to set locale %s (obtained from %s)\n", locale, locale_from); - return 2; + goto EXIT2; } pcretables = pcre_maketables(); } @@ -2986,7 +2994,7 @@ if (colour_option != NULL && strcmp(colour_option, "never") != 0) { fprintf(stderr, "pcregrep: Unknown colour setting \"%s\"\n", colour_option); - return 2; + goto EXIT2; } if (do_colour) { @@ -3026,7 +3034,7 @@ else if (strcmp(newline, "anycrlf") == 0 || strcmp(newline, "ANYCRLF") == 0) else { fprintf(stderr, "pcregrep: Invalid newline specifier \"%s\"\n", newline); - return 2; + goto EXIT2; } /* Interpret the text values for -d and -D */ @@ -3039,7 +3047,7 @@ if (dee_option != NULL) else { fprintf(stderr, "pcregrep: Invalid value \"%s\" for -d\n", dee_option); - return 2; + goto EXIT2; } } @@ -3050,7 +3058,7 @@ if (DEE_option != NULL) else { fprintf(stderr, "pcregrep: Invalid value \"%s\" for -D\n", DEE_option); - return 2; + goto EXIT2; } } @@ -3251,7 +3259,8 @@ EXIT: if (jit_stack != NULL) pcre_jit_stack_free(jit_stack); #endif -if (main_buffer != NULL) free(main_buffer); +free(main_buffer); +free((void *)pcretables); free_pattern_chain(patterns); free_pattern_chain(include_patterns); |