First of all you need to worry about legalities only if you wish to distribute your code. If it is for personal use or for an internal app for your organization you can go ahead and make any changes and integration you wish.
And even if you want to distribute your code, what you need to do is fine by GPLv2. To quote from the license (https://www.gnu.org/licenses/old-licenses/gpl-2.0)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Program,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Program, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote
it.
In addition, mere aggregation of another work not based on the Program
with the Program (or with a work based on the Program) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
Hope this helps.