kernel32/tests: Fix a crash on win9x (lpDefault is truncated inplace).

This commit is contained in:
Detlef Riekenberg 2008-07-27 15:29:31 +02:00 committed by Alexandre Julliard
parent 5816c3808e
commit 5437f4ce9c
1 changed files with 10 additions and 3 deletions

View File

@ -363,6 +363,7 @@ static void test_GetPrivateProfileString(void)
{ {
DWORD ret; DWORD ret;
CHAR buf[MAX_PATH]; CHAR buf[MAX_PATH];
CHAR def_val[MAX_PATH];
CHAR path[MAX_PATH]; CHAR path[MAX_PATH];
CHAR windir[MAX_PATH]; CHAR windir[MAX_PATH];
LPSTR tempfile; LPSTR tempfile;
@ -416,14 +417,18 @@ static void test_GetPrivateProfileString(void)
/* lpAppName is empty, lpDefault has trailing blank characters */ /* lpAppName is empty, lpDefault has trailing blank characters */
lstrcpyA(buf, "kumquat"); lstrcpyA(buf, "kumquat");
ret = GetPrivateProfileStringA("", "name1", "default ", /* lpDefault must be writeable (trailing blanks are removed inplace in win9x) */
lstrcpyA(def_val, "default ");
ret = GetPrivateProfileStringA("", "name1", def_val,
buf, MAX_PATH, filename); buf, MAX_PATH, filename);
ok(ret == 7, "Expected 7, got %d\n", ret); ok(ret == 7, "Expected 7, got %d\n", ret);
ok(!lstrcmpA(buf, "default"), "Expected \"default\", got \"%s\"\n", buf); ok(!lstrcmpA(buf, "default"), "Expected \"default\", got \"%s\"\n", buf);
/* lpAppName is empty, many blank characters in lpDefault */ /* lpAppName is empty, many blank characters in lpDefault */
lstrcpyA(buf, "kumquat"); lstrcpyA(buf, "kumquat");
ret = GetPrivateProfileStringA("", "name1", "one two ", /* lpDefault must be writeable (trailing blanks are removed inplace in win9x) */
lstrcpyA(def_val, "one two ");
ret = GetPrivateProfileStringA("", "name1", def_val,
buf, MAX_PATH, filename); buf, MAX_PATH, filename);
ok(ret == 7, "Expected 7, got %d\n", ret); ok(ret == 7, "Expected 7, got %d\n", ret);
ok(!lstrcmpA(buf, "one two"), "Expected \"one two\", got \"%s\"\n", buf); ok(!lstrcmpA(buf, "one two"), "Expected \"one two\", got \"%s\"\n", buf);
@ -473,7 +478,9 @@ static void test_GetPrivateProfileString(void)
/* lpKeyName is empty, lpDefault has trailing blank characters */ /* lpKeyName is empty, lpDefault has trailing blank characters */
lstrcpyA(buf, "kumquat"); lstrcpyA(buf, "kumquat");
ret = GetPrivateProfileStringA("section1", "", "default ", /* lpDefault must be writeable (trailing blanks are removed inplace in win9x) */
lstrcpyA(def_val, "default ");
ret = GetPrivateProfileStringA("section1", "", def_val,
buf, MAX_PATH, filename); buf, MAX_PATH, filename);
ok(ret == 7, "Expected 7, got %d\n", ret); ok(ret == 7, "Expected 7, got %d\n", ret);
ok(!lstrcmpA(buf, "default"), "Expected \"default\", got \"%s\"\n", buf); ok(!lstrcmpA(buf, "default"), "Expected \"default\", got \"%s\"\n", buf);