Jim Tcl
Check-in [24e8023431]
Not logged in

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:lsort -unique: Fix case with no duplicates

In this case the final element was written a second time.

Reported-by: Ryan Whitworth <me@ryanwhitworth.com> Signed-off-by: Steve Bennett <steveb@workware.net.au>

Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:24e8023431d3c2cb52d26cdb86fe732c1af207bb
User & Date: steveb@workware.net.au 2017-05-12 03:02:15
Context
2017-05-12
03:02
regexp: Fix bad memory access on missing close brace

For counted repetitions

Reported-by: Ryan Whitworth <me@ryanwhitworth.com> Signed-off-by: Steve Bennett <steveb@workware.net.au> check-in: 1cbabe444c user: steveb@workware.net.au tags: trunk

03:02
lsort -unique: Fix case with no duplicates

In this case the final element was written a second time.

Reported-by: Ryan Whitworth <me@ryanwhitworth.com> Signed-off-by: Steve Bennett <steveb@workware.net.au> check-in: 24e8023431 user: steveb@workware.net.au tags: trunk

03:02
format: Restrict formatted fields to a reasonable size

Calling the system sprintf() with overly long sizes can cause problems, so limit field size to 10000.

Reported-by: Ryan Whitworth <me@ryanwhitworth.com> Signed-off-by: Steve Bennett <steveb@workware.net.au> check-in: d9e8462879 user: steveb@workware.net.au tags: trunk

Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to jim.c.

6655
6656
6657
6658
6659
6660
6661

6662


6663

6664
6665
6666
6667
6668
6669
6670
        }
        else {
            /* No match, so keep the current source and move to the next destination */
            dst++;
        }
        ele[dst] = ele[src];
    }

    /* At end of list, keep the final element */


    ele[++dst] = ele[src];


    /* Set the new length */
    listObjPtr->internalRep.listValue.len = dst;
}

/* Sort a list *in place*. MUST be called with a non-shared list. */
static int ListSortElements(Jim_Interp *interp, Jim_Obj *listObjPtr, struct lsort_info *info)







>
|
>
>
|
>







6655
6656
6657
6658
6659
6660
6661
6662
6663
6664
6665
6666
6667
6668
6669
6670
6671
6672
6673
6674
        }
        else {
            /* No match, so keep the current source and move to the next destination */
            dst++;
        }
        ele[dst] = ele[src];
    }

    /* At end of list, keep the final element unless all elements were kept */
    dst++;
    if (dst < listObjPtr->internalRep.listValue.len) {
        ele[dst] = ele[src];
    }

    /* Set the new length */
    listObjPtr->internalRep.listValue.len = dst;
}

/* Sort a list *in place*. MUST be called with a non-shared list. */
static int ListSortElements(Jim_Interp *interp, Jim_Obj *listObjPtr, struct lsort_info *info)

Changes to regtest.tcl.

306
307
308
309
310
311
312





313
314
315
puts "TEST 42 PASSED"

# REGTEST 43
# too many flags to format
catch {format %----------------------------------------d 1}
puts "TEST 43 PASSED"






# TAKE THE FOLLOWING puts AS LAST LINE

puts "--- ALL TESTS PASSED ---"







>
>
>
>
>



306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
puts "TEST 42 PASSED"

# REGTEST 43
# too many flags to format
catch {format %----------------------------------------d 1}
puts "TEST 43 PASSED"

# REGTEST 44
# lsort -unique with no duplicate - invalid memory write
lsort -unique {a b c d}
puts "TEST 44 PASSED"

# TAKE THE FOLLOWING puts AS LAST LINE

puts "--- ALL TESTS PASSED ---"