Changeset e6503e9 in mainline


Ignore:
Timestamp:
2011-05-31T19:54:33Z (13 years ago)
Author:
Vojtech Horky <vojtechhorky@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
61ebd99b, c3dafe1
Parents:
50340bf
Message:

Fix bad pointer iteration

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/app/vuhid/device.c

    r50340bf re6503e9  
    9696    const char *id)
    9797{
    98         vuhid_interface_t *iface = ifaces[0];
    99         while (iface != NULL) {
    100                 if (str_cmp(iface->id, id) == 0) {
    101                         return iface;
     98        if ((ifaces == NULL) || (id == NULL)) {
     99                return NULL;
     100        }
     101        while (*ifaces != NULL) {
     102                if (str_cmp((*ifaces)->id, id) == 0) {
     103                        return *ifaces;
    102104                }
    103                 iface++;
    104         }
    105 
    106         return iface;
     105                ifaces++;
     106        }
     107
     108        return NULL;
    107109}
    108110
     
    119121        }
    120122
    121         // FIXME - we shall set vuhid_data to NULL in the main() rather
    122         // than to depend on individual interfaces
    123123        /* Already used interface. */
    124124        if (iface->vuhid_data != NULL) {
     
    166166         * Prepare new descriptors.
    167167         */
    168         printf("preparing descriptors...\n");
    169168        size_t descr_count = 0;
    170169        size_t total_descr_size = 0;
     
    273272        }
    274273
    275         printf("adding extra descriptors...\n");
    276274        /* Allocation is okay, we can (actually have to now) overwrite the
    277275         * original pointer.
Note: See TracChangeset for help on using the changeset viewer.