TSpinEdit的漏洞

来源:互联网 发布:附加数据库错误9003 编辑:程序博客网 时间:2024/06/05 22:33
<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 728x15, 创建于 08-4-23MSDN */google_ad_slot = "3624277373";google_ad_width = 728;google_ad_height = 15;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 160x600, 创建于 08-4-23MSDN */google_ad_slot = "4367022601";google_ad_width = 160;google_ad_height = 600;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>

最近在使用Samples页中的SpinEdit控件时,发现SpinEdit的最大值(MaxValue)和最小值(MinValue)的处理有漏洞。当最大值和最小值相等且不为零时,设置形同虚设;当最大值小于最小值时,SpinEdit的取值为最大值和最小值。查看Spin.pas时发现,SpinEdit的CheckValue函数如下:
function TSpinEdit.CheckValue (NewValue: LongInt): LongInt;
begin
  Result := NewValue;
  if (FMaxValue <> FMinValue) then
  begin
    if NewValue < FMinValue then
      Result := FMinValue
    else if NewValue > FMaxValue then
      Result := FMaxValue;
  end;
end;
可见没有对MaxValue = MinValue 且MinValue <> 0 及 MaxValue < MinValue 进行处理。所以在使用SpinEdit控件时应该在程序中对上述两种情况进行必要的处理。

我在发现这个问题的之前花费了不少时间调试程序,以为是代码的问题。结果发现是个BUG。这个问题可能早就有人发现并提出来了,只不过我没有看到而已。不过我还是把它贴出来,希望其他朋友不要在这个问题上浪费时间。呵呵,其实私底下还是想赚分的:)。

<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 728x15, 创建于 08-4-23MSDN */google_ad_slot = "3624277373";google_ad_width = 728;google_ad_height = 15;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 160x600, 创建于 08-4-23MSDN */google_ad_slot = "4367022601";google_ad_width = 160;google_ad_height = 600;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
原创粉丝点击