Fossil SCM

Revert two small sections of [4c3e1728e1b1a9cb] for cases which are not compatible with fsl_strdup()'s passing-on of NULL values. Found while investigating a presumably unrelated crash.

stephan 2025-10-21 13:49 trunk
Commit 20adff9572f49fa51c22e294a78315249258aeeb25012cb7a9984763f40e00e9
1 file changed +5 -5
+5 -5
--- src/search.c
+++ src/search.c
@@ -130,14 +130,14 @@
130130
search_end(p);
131131
}else{
132132
p = fossil_malloc(sizeof(*p));
133133
memset(p, 0, sizeof(*p));
134134
}
135
- p->zPattern = z = fossil_strdup(zPattern);
136
- p->zMarkBegin = fossil_strdup(zMarkBegin);
137
- p->zMarkEnd = fossil_strdup(zMarkEnd);
138
- p->zMarkGap = fossil_strdup(zMarkGap);
135
+ p->zPattern = z = mprintf("%s",zPattern);
136
+ p->zMarkBegin = mprintf("%s",zMarkBegin);
137
+ p->zMarkEnd = mprintf("%s",zMarkEnd);
138
+ p->zMarkGap = mprintf("%s",zMarkGap);
139139
p->fSrchFlg = fSrchFlg;
140140
blob_init(&p->snip, 0, 0);
141141
while( *z && p->nTerm<SEARCH_MAX_TERM ){
142142
while( *z && !ISALNUM(*z) ){ z++; }
143143
if( *z==0 ) break;
@@ -1076,11 +1076,11 @@
10761076
** causing errors in FTS5 searches with inputs which contain AND, OR,
10771077
** and symbols like #. The caller is responsible for passing the
10781078
** result to fossil_free().
10791079
*/
10801080
char *search_simplify_pattern(const char * zPattern){
1081
- char *zPat = fossil_strdup(zPattern);
1081
+ char *zPat = mprintf("%s",zPattern);
10821082
int i;
10831083
for(i=0; zPat[i]; i++){
10841084
if( (zPat[i]&0x80)==0 && !fossil_isalnum(zPat[i]) ) zPat[i] = ' ';
10851085
if( fossil_isupper(zPat[i]) ) zPat[i] = fossil_tolower(zPat[i]);
10861086
}
10871087
--- src/search.c
+++ src/search.c
@@ -130,14 +130,14 @@
130 search_end(p);
131 }else{
132 p = fossil_malloc(sizeof(*p));
133 memset(p, 0, sizeof(*p));
134 }
135 p->zPattern = z = fossil_strdup(zPattern);
136 p->zMarkBegin = fossil_strdup(zMarkBegin);
137 p->zMarkEnd = fossil_strdup(zMarkEnd);
138 p->zMarkGap = fossil_strdup(zMarkGap);
139 p->fSrchFlg = fSrchFlg;
140 blob_init(&p->snip, 0, 0);
141 while( *z && p->nTerm<SEARCH_MAX_TERM ){
142 while( *z && !ISALNUM(*z) ){ z++; }
143 if( *z==0 ) break;
@@ -1076,11 +1076,11 @@
1076 ** causing errors in FTS5 searches with inputs which contain AND, OR,
1077 ** and symbols like #. The caller is responsible for passing the
1078 ** result to fossil_free().
1079 */
1080 char *search_simplify_pattern(const char * zPattern){
1081 char *zPat = fossil_strdup(zPattern);
1082 int i;
1083 for(i=0; zPat[i]; i++){
1084 if( (zPat[i]&0x80)==0 && !fossil_isalnum(zPat[i]) ) zPat[i] = ' ';
1085 if( fossil_isupper(zPat[i]) ) zPat[i] = fossil_tolower(zPat[i]);
1086 }
1087
--- src/search.c
+++ src/search.c
@@ -130,14 +130,14 @@
130 search_end(p);
131 }else{
132 p = fossil_malloc(sizeof(*p));
133 memset(p, 0, sizeof(*p));
134 }
135 p->zPattern = z = mprintf("%s",zPattern);
136 p->zMarkBegin = mprintf("%s",zMarkBegin);
137 p->zMarkEnd = mprintf("%s",zMarkEnd);
138 p->zMarkGap = mprintf("%s",zMarkGap);
139 p->fSrchFlg = fSrchFlg;
140 blob_init(&p->snip, 0, 0);
141 while( *z && p->nTerm<SEARCH_MAX_TERM ){
142 while( *z && !ISALNUM(*z) ){ z++; }
143 if( *z==0 ) break;
@@ -1076,11 +1076,11 @@
1076 ** causing errors in FTS5 searches with inputs which contain AND, OR,
1077 ** and symbols like #. The caller is responsible for passing the
1078 ** result to fossil_free().
1079 */
1080 char *search_simplify_pattern(const char * zPattern){
1081 char *zPat = mprintf("%s",zPattern);
1082 int i;
1083 for(i=0; zPat[i]; i++){
1084 if( (zPat[i]&0x80)==0 && !fossil_isalnum(zPat[i]) ) zPat[i] = ' ';
1085 if( fossil_isupper(zPat[i]) ) zPat[i] = fossil_tolower(zPat[i]);
1086 }
1087

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button