Page MenuHomePhabricator

collection_view: fix a potentional error
ClosedPublic

Authored by akanad on Nov 22 2019, 2:05 AM.

Details

Summary

assign signed int value on bigger unsigned variable
can make information of the varaible lost.
this patch fix the problem.

Diff Detail

Repository
rEFL core/efl
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
akanad created this revision.Nov 22 2019, 2:05 AM
akanad requested review of this revision.Nov 22 2019, 2:05 AM
segfaultxavi requested changes to this revision.Nov 22 2019, 3:35 AM
segfaultxavi added a subscriber: segfaultxavi.
segfaultxavi added inline comments.
src/lib/elementary/efl_ui_collection_view.c
2305

This seems unrelated to the commit message.

Either remove this line or explain in the commit message why it is needed.

2329

This does not seem to do anything, besides maybe silence a warning. The compiler is already doing implicitly the same cast you are doing explicitly.

Do you have any specific scenario where this is causing problems and this patch actually fixes them?

This revision now requires changes to proceed.Nov 22 2019, 3:35 AM
  1. assigning negative int value into bigger unsigned int variable makes loss of meaning of sign bit.
  1. int new_id; can be a negative value, including -1.
  1. we know that efl_ui_position_manager_entity_relative_item returns only -1, for now.
  1. back to 3, we don't have a way to ensure the return value of the method to be -1 in the future.
  1. static analyzer pointed what I am saying.

so that

I wrote this patch to make logic ensuring that only positive int value would be assigned into uint64_t,
even if the result of the method has changed in the future to return various range of negative values.

Is it reasonable?

zmike added a subscriber: zmike.

Yea that's a classic uint overflow. @cedric !

akanad updated this revision to Diff 27363.Dec 6 2019, 12:30 AM
  • rebasing
  • ping
bu5hm4n accepted this revision.Dec 6 2019, 6:24 AM
This revision was not accepted when it landed; it landed in state Needs Review.Dec 6 2019, 6:36 AM
Closed by commit rEFL1aa5b0c2e88b: collection_view: fix a potentional error (authored by WhiskyKiloSq, committed by Marcel Hollerbach <mail@marcel-hollerbach.de>). · Explain Why
This revision was automatically updated to reflect the committed changes.