If malloc(0) returns NULL, the binary search in findSecLabels() will
probably go into an infinite loop when there are no security labels,
because NULL-1 is greater than NULL after wraparound.
(We've seen this pathology before ... I wonder whether there's a way to
detect the class of bugs automatically?)
Diagnosis and patch by Steve Singer, cosmetic adjustments by me
do_sql_command(g_conn, "SET quote_all_identifiers = true");
/*
- * Disables security label support if server version < v9.1.x
+ * Disable security label support if server version < v9.1.x (prevents
+ * access to nonexistent pg_seclabel catalog)
*/
- if (!no_security_labels && g_fout->remoteVersion < 90100)
+ if (g_fout->remoteVersion < 90100)
no_security_labels = 1;
/*
if (nlabels < 0)
nlabels = collectSecLabels(fout, &labels);
+ if (nlabels <= 0) /* no labels, so no match is possible */
+ {
+ *items = NULL;
+ return 0;
+ }
+
/*
* Do binary search to find some item matching the object.
*/