X-Git-Url: http://sru.miketaylor.org.uk/?a=blobdiff_plain;f=src%2Ffilter_multi.cpp;h=baadef4d9ad876b33e5bfa20f7cc69fcaba11d65;hb=8ced8e7b5de3ecba12ac68ce5c5e8cddf40d800f;hp=5efc6d33d7941e4e5275ea0a7af2e7ceae0d8fd3;hpb=2ed18a489ee3765497d711432fdaeab9b40fd844;p=metaproxy-moved-to-github.git diff --git a/src/filter_multi.cpp b/src/filter_multi.cpp index 5efc6d3..baadef4 100644 --- a/src/filter_multi.cpp +++ b/src/filter_multi.cpp @@ -1,5 +1,5 @@ /* This file is part of Metaproxy. - Copyright (C) 2005-2012 Index Data + Copyright (C) 2005-2013 Index Data Metaproxy is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free @@ -573,7 +573,7 @@ void yf::Multi::Frontend::record_diagnostics(Z_Records *records, { Z_DiagRec **n = (Z_DiagRec **) odr_malloc(odr, - (1+z_diag->num_diagRecs) * sizeof(*n)); + (1 + z_diag->num_diagRecs) * sizeof(*n)); memcpy(n, z_diag->diagRecs, z_diag->num_diagRecs * sizeof(*n)); z_diag->diagRecs = n; @@ -586,8 +586,24 @@ void yf::Multi::Frontend::record_diagnostics(Z_Records *records, } else if (records->which == Z_Records_multipleNSD) { - // we may set this multiple times (TOO BAD!) - z_diag = records->u.multipleNonSurDiagnostics; + Z_DiagRecs * dr =records->u.multipleNonSurDiagnostics; + + if (!z_diag) + { + z_diag = (Z_DiagRecs *) odr_malloc(odr, sizeof(*z_diag)); + z_diag->num_diagRecs = 0; + z_diag->diagRecs = 0; + } + Z_DiagRec **n = (Z_DiagRec **) + odr_malloc(odr, + (dr->num_diagRecs + z_diag->num_diagRecs) * + sizeof(*n)); + if (z_diag->num_diagRecs) + memcpy(n, z_diag->diagRecs, z_diag->num_diagRecs * sizeof(*n)); + memcpy(n + z_diag->num_diagRecs, + dr->diagRecs, dr->num_diagRecs * sizeof(*n)); + z_diag->diagRecs = n; + z_diag->num_diagRecs += dr->num_diagRecs; } else no_successful++; // probably piggyback