treewide: fix many null dereference reports

Add defensive handling for several NULL allocation and formatting paths reported across issues #820-#829.

Fixes #820, fixes #821, fixes #822, fixes #823, fixes #825, fixes #828
This commit is contained in:
Roland C. Dowdeswell
2026-05-27 18:31:12 +01:00
committed by Nico Williams
parent 9a9da70626
commit de7aa57362
4 changed files with 15 additions and 1 deletions
+6
View File
@@ -612,6 +612,12 @@ osad(const char *s1, const char *s2)
row0 = calloc(l2 + 1, sizeof(int));
row1 = calloc(l2 + 1, sizeof(int));
row2 = calloc(l2 + 1, sizeof(int));
if (row0 == NULL || row1 == NULL || row2 == NULL) {
free(row0);
free(row1);
free(row2);
return INT_MAX;
}
for (j = 0; j < l2 + 1; j++)
row1[j] = j;