View Single Post
Posts: 3,074 | Thanked: 12,960 times | Joined on Mar 2010 @ Sofia,Bulgaria
#1503
Originally Posted by marxian View Post
Segfault should be fixed now in qyoutube 0.1.6.
If https://github.com/marxoft/qyoutube/...823733a2a1b7d8 is the commit that is supposed to fix the segfault, I am afraid there is still a possibility for it .

Imagine getVideoInfo() called twice in a row. On the first call member variable reply is NULL, so we are safe (https://github.com/marxoft/qyoutube/...quest.cpp#L174 doesn;t get called). On lines 180 and 181 a new reply is created and finished() signal is connected. at this point we have a valid pointer in reply member variable. Before the finished() signal is emitted, a second getVideoInfo() (or some of the other function which uses reply) call is issued (whoever is the one that calls it). Now, on line 174 the first reply will get deleted, leading to use-after-free and thus - a segfault.

I think you should either have a separate QNetworkReply* for each function that issues a request and fail the function if there is already a reply which is not finished for it, or remove reply member altogether and use qobject_cast(sender()); to have the needed QNetworkReply * for getting the result and calling deleteLater()

I'll cook a quick patch on github using the second approach and will request a merge.

EDIT: Maybe the best approach is to use QSignalMapper
EDIT2: https://github.com/marxoft/qyoutube/pull/1
__________________
Never fear. I is here.

720p video support on N900,SmartReflex on N900,Keyboard and mouse support on N900
Nothing is impossible - Stable thumb2 on n900

Community SSU developer
kernel-power developer and maintainer


Last edited by freemangordon; 2015-11-08 at 20:06.
 

The Following 2 Users Say Thank You to freemangordon For This Useful Post: