win32env.patch
application/octet-stream
Filename: win32env.patch
Type: application/octet-stream
Part: 0
Message:
win32env.c bug with no msvcrt
Patch
Same data as JSON:
GET /api/v1/attachments/:id/patch
the parsed metadata as JSON — format, series position, per-file stats; never the diff bytes.
API reference →
Format: unified
| File | + | − |
|---|---|---|
| src/port/win32env.c | 13 | 8 |
diff --git a/src/port/win32env.c b/src/port/win32env.c
index a2595a8..e5c0f0d 100644
--- a/src/port/win32env.c
+++ b/src/port/win32env.c
@@ -40,15 +40,20 @@ pgwin32_putenv(const char *envval)
if (putenvFunc == NULL)
{
hmodule = GetModuleHandle("msvcrt");
- if (hmodule == NULL)
- return 1;
- putenvFunc = (PUTENVPROC) GetProcAddress(hmodule, "_putenv");
- if (putenvFunc == NULL)
- return 1;
+ if (hmodule != NULL)
+ {
+ /*
+ * If the module is found, attempt to find the function. If not, that just
+ * means we're not linked with msvcrt, so fall through and make our other
+ * modifications anyway.
+ * Ignore any errors and update whatever we can, since callers don't
+ * check the return value anyway.
+ */
+ putenvFunc = (PUTENVPROC) GetProcAddress(hmodule, "_putenv");
+ if (putenvFunc != NULL)
+ putenvFunc(envval);
+ }
}
- ret = putenvFunc(envval);
- if (ret != 0)
- return ret;
#endif /* _MSC_VER >= 1300 */