On Saturday, December 7, 2013 1:49:37 PM UTC+4, Ken Takata wrote:
> Hi,
>
> After 7.4.081 static analysis with MSVC10 (Windows SDK 7.1) is supported.
> I compiled 7.4.110 with MSVC10 enabling the static analysis. I attach the
> result of the analysis. Maybe the most of the warnings are false positive,
> but I found some parts which should be fixed.
>
> I fixed the following four warnings:
> c:\work\vim-msvc\src\os_win32.c(2603) : warning C6054: String 'szTrueName'
> might not be zero-terminated: Lines: 2506, 2507, 2508, 2509, 2510, 2511,
> 2512, 2513, 2514, 2516, 2517, 2523, 2524, 2526, 2534, 2603
> c:\work\vim-msvc\src\os_win32.c(2599) : warning C6001: Using uninitialized
> memory 'hFind': Lines: 2506, 2507, 2508, 2509, 2510, 2511, 2512, 2513, 2514,
> 2516, 2517, 2523, 2524, 2526, 2534, 2537, 2540, 2541, 2542, 2544, 2542, 2546,
> 2550, 2551, 2552, 2560, 2599
> c:\work\vim-msvc\src\os_win32.c(2756) : warning C6054: String 'szTrueName'
> might not be zero-terminated: Lines: 2618, 2619, 2620, 2621, 2622, 2623,
> 2624, 2625, 2626, 2628, 2629, 2632, 2635, 2664, 2668, 2669, 2671, 2679, 2756
> c:\work\vim-msvc\src\os_win32.c(6282) : warning C6001: Using uninitialized
> memory 'argv': Lines: 6249, 6250, 6251, 6253, 6254, 6256, 6257, 6259, 6260,
> 6261, 6263, 6266, 6269, 6261, 6263, 6266, 6269, 6272, 6273, 6272, 6274, 6275,
> 6261, 6281, 6282
>
> Please check the attached patch.
>
> Additionally, I found one suspicious part:
> c:\work\vim-msvc\src\if_py_both.h(3008) : warning C6246: Local declaration of
> 'todecref' hides declaration of the same name in outer scope. For additional
> information, see previous declaration at line '2930' of
> 'c:\work\vim-msvc\src\if_py_both.h': Lines: 2930
>
> Maybe it's better to ask to ZyX.
> It seems that Py_XDECREF() is not called after the call of StringToChars() in
> the line 3010. Is it OK?
>
> Regards,
> Ken Takata
No, it is wrong. I have posted the patch:
https://groups.google.com/forum/#!topic/vim_dev/n8A4XFC2SEY, also here:
# HG changeset patch
# User ZyX <[email protected]>
# Date 1386410239 -14400
# Sat Dec 07 13:57:19 2013 +0400
# Branch fix-sa-warning-1
# Node ID c87415f3c0adc44106d6c2944c53f721c94cc6f5
# Parent 486655e0c5a21469364d3cf895535137f09b3724
Fix error found by @Ken Takata
diff -r 486655e0c5a2 -r c87415f3c0ad src/if_py_both.h
--- a/src/if_py_both.h Thu Nov 28 19:27:30 2013 +0100
+++ b/src/if_py_both.h Sat Dec 07 13:57:19 2013 +0400
@@ -3005,11 +3005,14 @@
else
{
char_u *val;
- PyObject *todecref;
-
- if ((val = StringToChars(valObject, &todecref)))
+ PyObject *todecref2;
+
+ if ((val = StringToChars(valObject, &todecref2)))
+ {
ret = set_option_value_for(key, 0, val, opt_flags,
self->opt_type, self->from);
+ Py_XDECREF(todecref2);
+ }
else
ret = -1;
}
--
--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
---
You received this message because you are subscribed to the Google Groups
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.
*** /tmp/extdiff.E8EA8e/vim-small-patches.486655e0c5a2/src/if_py_both.h 2013-12-07 14:01:54.979342986 +0400
--- vim-small-patches.c87415f3c0ad/src/if_py_both.h 2013-12-07 14:01:54.982342986 +0400
***************
*** 3005,3015 ****
else
{
char_u *val;
! PyObject *todecref;
! if ((val = StringToChars(valObject, &todecref)))
ret = set_option_value_for(key, 0, val, opt_flags,
self->opt_type, self->from);
else
ret = -1;
}
--- 3005,3018 ----
else
{
char_u *val;
! PyObject *todecref2;
! if ((val = StringToChars(valObject, &todecref2)))
! {
ret = set_option_value_for(key, 0, val, opt_flags,
self->opt_type, self->from);
+ Py_XDECREF(todecref2);
+ }
else
ret = -1;
}