Skip to content

Commit

Permalink
Fix null pointer dereference in pj_datum_tranform() caused by d0dbf48
Browse files Browse the repository at this point in the history
  • Loading branch information
rouault committed Jan 25, 2018
1 parent 29cb4a0 commit aff1011
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/pj_transform.c
Original file line number Diff line number Diff line change
Expand Up @@ -756,7 +756,8 @@ int pj_datum_transform( PJ *srcdefn, PJ *dstdefn,
/* If the gridlist has either "@null" or "null" as its only */
/* grid we don't change the ellipsoid parameters, since the */
/* datum shift to WGS84 was not performed in practice. */
if ( strcmp("@null", srcnadgrids) && strcmp("null", srcnadgrids) ) {
if ( srcnadgrids != NULL &&
strcmp("@null", srcnadgrids) && strcmp("null", srcnadgrids) ) {
src_a = SRS_WGS84_SEMIMAJOR;
src_es = SRS_WGS84_ESQUARED;
}
Expand All @@ -768,7 +769,8 @@ int pj_datum_transform( PJ *srcdefn, PJ *dstdefn,
/* If the gridlist has either "@null" or "null" as its only */
/* grid we don't change the ellipsoid parameters, since the */
/* datum shift to WGS84 will not be performed. */
if ( strcmp("@null", dstnadgrids) && strcmp("null", dstnadgrids) ) {
if ( dstnadgrids != NULL &&
strcmp("@null", dstnadgrids) && strcmp("null", dstnadgrids) ) {
dst_a = SRS_WGS84_SEMIMAJOR;
dst_es = SRS_WGS84_ESQUARED;
}
Expand Down

1 comment on commit aff1011

@kbevers
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! One day I'll get the hang of these bloody string operations, I promise!

Please sign in to comment.