xcode - Weird behaviour of C strcpy -
I wrote a small program in C. It's fully compiled and works, when I make it my This works 4 times out of 10 times. In the other 6 times, Xcode is telling me that it is The computed size for The last part should be '+6' because you need Makefile and
swing , however, this function does not like it in Xcode (or it behaves like this As it should and the chapra is ignoring it).
size_t getUrlForArgandPlatform char ** dest, const char * arg, const char * platform) {int isLinux = strcmp (forums, "Linux"); Int isOSX = strcmp (forums, "Darwin"); Char * platformUrlDelimiter = malloc (6 + 1); If (isLinux == 0) {strcpy (platformUrlDelimiter, "linux"); } And if (isOSX == 0) {strcpy (platformUrlDelimiter, "osx"); } Other {strcpy (platformUrlDelimiter, "normal"); } Int length = (int) strlen (kBaseUrl); Length + = strollon (platformUrlDelimiter); Length + = stellen (arg); Length + = 5; Four * buffer = (four *) maulok (length); If (buffer == faucet) {exit (EXIT_FAILURE); } Strcpy (buffer, cabage url); Dome (buffer, "/"); Vertical (buffer, platform url, delimiter); Dome (buffer, "/"); Dome (buffer, RGR); Dome (buffer, ".md"); * Dest = Molok (Stellon (buffer) + 1); Streakpy (* dist, buffer); Free (platformUrlDelimiter); Free (buffer); Return Strane (buffer) + 1; }
strcpy (* dest, buffer) code> SIGBRT . If I take a look at the debugger, then I think that the
buffer has the same string twice. Why?
buffer is not perfect:
integer = length (int) strlen (kBaseUrl); Length + = strollon (platformUrlDelimiter); Length = = stellen (arg); Length + = 5;
"md" for 2 times
"/" .
NUL to finish more .
Comments
Post a Comment