Compartilhar via


PREfast Warning 298 (Windows CE 5.0)

Send Feedback

298 - Using a read-only string <pointer> as a writable string argument.
Consequence: This will attempt to write into static read-only memory and cause random crashes.

This warning indicates a potentially dangerous use of a constant string as an argument to a function that might modify the contents of that string.

Because the compiler allocates constant strings in a static read-only memory, attempts to modify it cause access violations and random crashes.

Storing the constant string into a local array and using the array as the argument to the function can avoid this.

Example

Defective Source

CreateProcessA(NULL,
               "MyApp.exe -?",
               NULL,
               NULL,
               FALSE,
               0,
               NULL,
               NULL,
               &Si,
               &Pi);

Corrected Source

char szCmdLine[] = "MyApp.exe -?";

CreateProcessA(NULL,
               szCmdLine,
               NULL,
               NULL,
               FALSE,
               0,
               NULL,
               NULL,
               &Si,
               &Pi);

Send Feedback on this topic to the authors

Feedback FAQs

© 2006 Microsoft Corporation. All rights reserved.