Commit 160acba232a60a85513cae0aaa6c704ea72f0c43

Authored by Silvan Calarco
1 parent 374df0a529
Exists in master

reports.c: generateHTML_SRPMSFiles: fix a segfault when writing multiple providers

Showing 1 changed file with 44 additions and 43 deletions Side-by-side Diff

... ... @@ -1165,49 +1165,50 @@
1165 1165 /* list build requirements */
1166 1166 fprintf(fout, "<tr><td nowrap>Build requirements:</td><td><font size=\"-1\">");
1167 1167  
1168   - for (i = 0; i < currheadersourcelist->requirecount; i++) {
1169   - if (currheadersourcelist->require[i]->resolved) {
1170   - if (currheadersourcelist->require[i]->resolved->numbuildproviders == 0) {
1171   - // missing provider
1172   - fprintf(fout,"<b>%s(unresolved)</b>",currheadersourcelist->require[i]->resolved->name);
1173   - } else if (currheadersourcelist->require[i]->resolved->numbuildproviders == 1) {
1174   - // single provider
1175   - if ((i == 0 ||
1176   - strcmp(currheadersourcelist->require[i-1]->name,
1177   - currheadersourcelist->require[i]->name)) &&
1178   - strcmp(currheadersourcelist->name,
1179   - currheadersourcelist->require[i]->name)) {
1180   - fprintf(fout,"<a href=\"%stag=%s&amp;pkg=%s.%s\">%s</a>",
1181   - configtag->configdefaults->url_prefix,
1182   - configtag->repository[currheadersourcelist->require[i]->resolved->buildprovider[0]->altrepository]->tag,
1183   - currheadersourcelist->require[i]->resolved->name,
1184   - configtag->arch[0],
1185   - currheadersourcelist->require[i]->resolved->name);
1186   - if ((configtag->repository_level > 0) &&
1187   - currheadersourcelist->require[i]->resolved->buildprovider[0]->sourceheader &&
1188   - (currheadersourcelist->require[i]->resolved->buildprovider[0]->altrepository == configtag->repository_level)) {
1189   - snprintf(buffer, PATH_MAX, "has build requirement %s which is only provided in this repository",
1190   - currheadersourcelist->require[i]->resolved->name);
1191   - addWarning(currheadersourcelist, buffer);
1192   - }
1193   - }
1194   - } else {
1195   - // multiple providers
1196   - if (i == 0 ||
1197   - strcmp(currheadersourcelist->require[i-1]->resolved->name,
1198   - currheadersourcelist->require[i]->resolved->name))
1199   - fprintf(fout,"<i>%s</i>(",currheadersourcelist->require[i]->resolved->name);
1200   - for (j = 0; j < currheadersourcelist->require[i]->resolved->numbuildproviders; j++) {
1201   - fprintf(fout,"<a href=\"%stag=%s&amp;pkg=%s.%s\">%s</a>",
1202   - configtag->configdefaults->url_prefix,
1203   - configtag->repository[currheadersourcelist->require[i]->resolved->buildprovider[j]->altrepository]->tag,
1204   - currheadersourcelist->require[i]->resolved->buildprovider[j]->name,
1205   - configtag->arch[0],
1206   - currheadersourcelist->require[i]->resolved->buildprovider[j]->name);
1207   - if (j+1 < currheadersourcelist->require[i]->resolved->numbuildproviders) fprintf(fout,"|");
1208   - }
1209   - fprintf(fout,")");
1210   - } // if numproviders
  1168 + for (i = 0; i < currheadersourcelist->requirecount; i++) {
  1169 + if (currheadersourcelist->require[i]->resolved) {
  1170 + if (currheadersourcelist->require[i]->resolved->numbuildproviders == 0) {
  1171 + // missing provider
  1172 + fprintf(fout,"<b>%s(unresolved)</b>",currheadersourcelist->require[i]->resolved->name);
  1173 + } else if (currheadersourcelist->require[i]->resolved->numbuildproviders == 1) {
  1174 + // single provider
  1175 + if ((i == 0 ||
  1176 + strcmp(currheadersourcelist->require[i-1]->name,
  1177 + currheadersourcelist->require[i]->name)) &&
  1178 + strcmp(currheadersourcelist->name,
  1179 + currheadersourcelist->require[i]->name)) {
  1180 + fprintf(fout,"<a href=\"%stag=%s&amp;pkg=%s.%s\">%s</a>",
  1181 + configtag->configdefaults->url_prefix,
  1182 + configtag->repository[currheadersourcelist->require[i]->resolved->buildprovider[0]->altrepository]->tag,
  1183 + currheadersourcelist->require[i]->resolved->name,
  1184 + configtag->arch[0],
  1185 + currheadersourcelist->require[i]->resolved->name);
  1186 + if ((configtag->repository_level > 0) &&
  1187 + currheadersourcelist->require[i]->resolved->buildprovider[0]->sourceheader &&
  1188 + (currheadersourcelist->require[i]->resolved->buildprovider[0]->altrepository == configtag->repository_level)) {
  1189 + snprintf(buffer, PATH_MAX, "has build requirement %s which is only provided in this repository",
  1190 + currheadersourcelist->require[i]->resolved->name);
  1191 + addWarning(currheadersourcelist, buffer);
  1192 + }
  1193 + }
  1194 + } else {
  1195 + // multiple providers
  1196 + if (i == 0 ||
  1197 + !currheadersourcelist->require[i-1]->resolved ||
  1198 + strcmp(currheadersourcelist->require[i-1]->resolved->name,
  1199 + currheadersourcelist->require[i]->resolved->name))
  1200 + fprintf(fout,"<i>%s</i>(",currheadersourcelist->require[i]->resolved->name);
  1201 + for (j = 0; j < currheadersourcelist->require[i]->resolved->numbuildproviders; j++) {
  1202 + fprintf(fout,"<a href=\"%stag=%s&amp;pkg=%s.%s\">%s</a>",
  1203 + configtag->configdefaults->url_prefix,
  1204 + configtag->repository[currheadersourcelist->require[i]->resolved->buildprovider[j]->altrepository]->tag,
  1205 + currheadersourcelist->require[i]->resolved->buildprovider[j]->name,
  1206 + configtag->arch[0],
  1207 + currheadersourcelist->require[i]->resolved->buildprovider[j]->name);
  1208 + if (j+1 < currheadersourcelist->require[i]->resolved->numbuildproviders) fprintf(fout,"|");
  1209 + }
  1210 + fprintf(fout,")");
  1211 + } // if numproviders
1211 1212 if (currheadersourcelist->require[i]->flags & (RPMSENSE_LESS|RPMSENSE_GREATER|RPMSENSE_EQUAL)) {
1212 1213 fprintf(fout,"[");
1213 1214 if (currheadersourcelist->require[i]->flags & RPMSENSE_LESS) fprintf(fout, "<");