Hi!

I just noticed that your alternate version of vasnprintf calls realloc on
the *strp argument but when I look at my system's version it seems to call
malloc and just assign the result and given that one could imagine people
calling it using an uninitilaized pointer then that behaviour sounds more
correct.

In short:

Should

{
  char* s;
  asprintf(&s, "foo");
}

be undefined or should

{
  char* s = (char*)malloc(17);
  asprintf(&s, "foo");
}

leak memory?

One could also look at the case

{
  char buf[17];
  char* s = buf;
  asprintf(&s, "foo");
}

which is undefined with the current implementation and valid if the realloc
is replaced with a malloc.

/MF

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Net-snmp-coders mailing list
Net-snmp-coders@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/net-snmp-coders

Reply via email to