Menu

#209 tcldom-libxml2.c:2065: possible bad array index ?

C/C++ Module
open
nobody
None
5
2015-06-03
2014-12-16
dcb
No

[tcldom-libxml2.c:2065]: (style) Array index 'idx' is used before limits check.

Source code is

for (idx = 0; buf[idx] != ':' && idx < len; idx++) ;

Suggest sanity check array index before use.

Discussion

  • Wolfgang S. Kechel

    The code is correct since Tcl_GetStringFromObject returns a pointer to a \0-terminated string that is not counted when determining the length.

     
  • dcb

    dcb - 2015-06-02

    The code is correct

    Maybe I've been slightly less than clear. The issue
    isn't the correctness of the code.

    Suggest re-read the message produced.

    The code is bad style and so IMHO and the static analysis tool's opinion needs rework.

     
  • Wolfgang S. Kechel

    OK, I see the point. It will be fixed soon.

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.