With a called function MyFn
that allocates memory:
Error MyFn(_Outptr_result_maybenull_ OBJ** const objs,
_Out_ unsigned int* const numObjs) {
...
}
int main(void) {
OBJ* objs = NULL;
unsigned int numObjs = 0;
MyFn(&objs, &numObjs);
if (objs != NULL) {
for (int i = 0; i < numObjs; i++) {
OBJ* obj = objs[i]; // Reading invalid data from objs.
}
}
}
Is it possible to annotate numObjs
as the number of OBJ*
written to objs
so that SAL doesn't warn me that I'm potentially reading invalid data while iterating?