From 97812949e1bb99743c25e572cc1a3fde483931f3 Mon Sep 17 00:00:00 2001 From: Adam Dickmeiss Date: Wed, 10 Oct 2012 21:21:33 +0200 Subject: [PATCH] Avoid session memory for client sort stuff The session mem gets reset and results in sort_strategy and sort_critiera being corrupted - to empty strings or even vialation. --- src/client.c | 13 +++++++++--- test/test_url_18.res | 56 +++++++++++++++++++++++++------------------------- 2 files changed, 38 insertions(+), 31 deletions(-) diff --git a/src/client.c b/src/client.c index 189bb61..426b289 100644 --- a/src/client.c +++ b/src/client.c @@ -969,6 +969,8 @@ int client_destroy(struct client *c) xfree(c->addinfo); c->addinfo = 0; xfree(c->id); + xfree(c->sort_strategy); + xfree(c->sort_criteria); assert(!c->connection); facet_limits_destroy(c->facet_limits); @@ -1369,7 +1371,6 @@ int client_parse_query(struct client *cl, const char *query, int client_parse_sort(struct client *cl, struct reclist_sortparms *sp) { - struct session *se = client_get_session(cl); if (sp) { const char *sort_strategy_and_spec = @@ -1396,18 +1397,24 @@ int client_parse_sort(struct client *cl, struct reclist_sortparms *sp) if (!cl->sort_criteria || strcmp(cl->sort_criteria, p)) cl->same_search = 0; if (cl->same_search == 0) { - cl->sort_strategy = nmem_strdup(se->nmem, strategy); - cl->sort_criteria = nmem_strdup(se->nmem, p); + xfree(cl->sort_strategy); + cl->sort_strategy = xstrdup(strategy); + xfree(cl->sort_criteria); + cl->sort_criteria = xstrdup(p); } } else { yaz_log(YLOG_LOG, "Client %s: Invalid sort strategy and spec found %s", client_get_id(cl), sort_strategy_and_spec); + xfree(cl->sort_strategy); cl->sort_strategy = 0; + xfree(cl->sort_criteria); cl->sort_criteria = 0; } } else { yaz_log(YLOG_LOG, "Client %s: No sort strategy and spec found.", client_get_id(cl)); + xfree(cl->sort_strategy); cl->sort_strategy = 0; + xfree(cl->sort_criteria); cl->sort_criteria = 0; } diff --git a/test/test_url_18.res b/test/test_url_18.res index dbd671c..9af6f33 100644 --- a/test/test_url_18.res +++ b/test/test_url_18.res @@ -6,10 +6,34 @@ 0 10 + STATEWIDE PLANNING + This data set contains: 1970 digitized land use maps, 1970 digitized zoning maps, active agricultural areas maps (1979-1980), maps displaying current National Flood Insurance Program data, locational guide map of the State Policies Plan for Conservation and Development of Connecticut (1987-1992), 1970 land use statistical data and 1970 municipal zoning data, proposed sewer service areas maps (1978) - DEP has update of this information, water conservation handbooks, and various reports and maps of the areawide Waste Treatment Management Planning Program (208) + + STATEWIDE PLANNING + This data set contains: 1970 digitized land use maps, 1970 digitized zoning maps, active agricultural areas maps (1979-1980), maps displaying current National Flood Insurance Program data, locational guide map of the State Policies Plan for Conservation and Development of Connecticut (1987-1992), 1970 land use statistical data and 1970 municipal zoning data, proposed sewer service areas maps (1978) - DEP has update of this information, water conservation handbooks, and various reports and maps of the areawide Waste Treatment Management Planning Program (208) + 1960-PRESENT + + 1 + content: title statewide planning author medium book + + + WATER WELL DATA + This database contains the following information on water wells in Nevada: driller's name, owner's name, location, formations encountered, lithologic descriptions, water level, and water quality + + WATER WELL DATA + This database contains the following information on water wells in Nevada: driller's name, owner's name, location, formations encountered, lithologic descriptions, water level, and water quality + 1930-PRESENT + + 1 + content: title water well data author medium book + + UTAH GEOLOGICAL AND MINERAL SURVEY PUBLICATIONS Publications of the Utah Geological and Mineral Survey include reports of investigation, special studies, bulletins, open-file reports, geologic map of Utah, publications of geological societies, geologic and oil and mineral maps, coal monographs, circulars, water resource bulletins, and reprints of articles + name="marcserver" checksum="4291493253"> UTAH GEOLOGICAL AND MINERAL SURVEY PUBLICATIONS Publications of the Utah Geological and Mineral Survey include reports of investigation, special studies, bulletins, open-file reports, geologic map of Utah, publications of geological societies, geologic and oil and mineral maps, coal monographs, circulars, water resource bulletins, and reprints of articles -PRESENT @@ -21,7 +45,7 @@ COAL SAMPLE BANK This data set contains methane data, chemical analysis data, and petrographic analysis data on core samples in Utah + name="marcserver" checksum="4287955038"> COAL SAMPLE BANK This data set contains methane data, chemical analysis data, and petrographic analysis data on core samples in Utah -PRESENT @@ -33,7 +57,7 @@ FRESH WATER WETLANDS MAPS Contained are a series of 1:50,000 scale maps showing regulated and unregulated fresh water wetlands in the organized territories. Included is a table describing each mapped wetland + name="marcserver" checksum="4284416823"> FRESH WATER WETLANDS MAPS Contained are a series of 1:50,000 scale maps showing regulated and unregulated fresh water wetlands in the organized territories. Included is a table describing each mapped wetland @@ -44,7 +68,7 @@ MAINE GEOLOGICAL SURVEY BEDROCK WATER WELL INVENTORY This data set contains a series of well inventory maps stored on tape. The series has no indexing + name="marcserver" checksum="4280878608"> MAINE GEOLOGICAL SURVEY BEDROCK WATER WELL INVENTORY This data set contains a series of well inventory maps stored on tape. The series has no indexing 1972-PRESENT @@ -53,30 +77,6 @@ content: title maine geological survey bedrock water well inventory author medium book - WATER WELL DATA - This database contains the following information on water wells in Nevada: driller's name, owner's name, location, formations encountered, lithologic descriptions, water level, and water quality - - WATER WELL DATA - This database contains the following information on water wells in Nevada: driller's name, owner's name, location, formations encountered, lithologic descriptions, water level, and water quality - 1930-PRESENT - - 1 - content: title water well data author medium book - - - STATEWIDE PLANNING - This data set contains: 1970 digitized land use maps, 1970 digitized zoning maps, active agricultural areas maps (1979-1980), maps displaying current National Flood Insurance Program data, locational guide map of the State Policies Plan for Conservation and Development of Connecticut (1987-1992), 1970 land use statistical data and 1970 municipal zoning data, proposed sewer service areas maps (1978) - DEP has update of this information, water conservation handbooks, and various reports and maps of the areawide Waste Treatment Management Planning Program (208) - - STATEWIDE PLANNING - This data set contains: 1970 digitized land use maps, 1970 digitized zoning maps, active agricultural areas maps (1979-1980), maps displaying current National Flood Insurance Program data, locational guide map of the State Policies Plan for Conservation and Development of Connecticut (1987-1992), 1970 land use statistical data and 1970 municipal zoning data, proposed sewer service areas maps (1978) - DEP has update of this information, water conservation handbooks, and various reports and maps of the areawide Waste Treatment Management Planning Program (208) - 1960-PRESENT - - 1 - content: title statewide planning author medium book - - INLAND WETLANDS OF CONNECTICUT This data set contains inland wetlands, as defined by State statute, which are delineated at a scale of 1:12,000, based predominantly on location of wet soils