Am Montag, den 03.09.2018, 14:42 +0100 schrieb Emil Velikov: > > struct virgl_hw_res **new_bo = > > > + new_nres * sizeof(struct > > virgl_hw_buf*)); > > + if (!new_ptr) { > > + fprintf(stderr,"failure to add relocation %d, %d\n", > > cbuf->cres, new_nres); > > return; > > } > > + cbuf->res_bo = new_ptr; > > + > > + new_ptr = REALLOC(cbuf->res_hlist, cbuf->nres * > > sizeof(uint32_t), > > uint32_t *new_hlist = > > > + new_nres * sizeof(uint32_t)); > > + if (!new_ptr) { > > + fprintf(stderr,"failure to add hlist relocation %d, > > %d\n", cbuf->cres, cbuf->nres); > > FREE(new_bo); I don't think this is correct: as far as I understand how ralloc works, then if the realloc succeeds, then the old cbuf->res_bo is either invalidated, or points to the same area like new_bo. In both cases free will free the memory where resource data is stored, and later at cleanup this will lead to problems.
Best, Gert > > + return; > > + } > > + cbuf->res_hlist = new_ptr; > > + /* This is not perfect, because when the first re-allocation > > succeeds but > > + * the second failes the first old_size will be wrong, but > > currently it > > + * isn't used anyway. */ > > Now you can drop the comment. > > Aside: the old_size of REALLOC could/should go - debug_realloc can > use > old_hdr->size. > Using sizeof(instance) should be clearer and more consistent with the > rest of winsys/virgl. > > -Emil > _______________________________________________ > mesa-dev mailing list > mesa-dev@lists.freedesktop.org > https://lists.freedesktop.org/mailman/listinfo/mesa-dev _______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev