Opened 8 years ago

Closed 8 years ago

#6206 closed defect (fixed)

AmigoCloud: various issues reported by Coverity Scan

Reported by: Even Rouault Owned by: vchernetsky
Priority: normal Milestone:
Component: default Version: unspecified
Severity: normal Keywords:
Cc:

Description

** CID 1338315:  Null pointer dereferences  (FORWARD_NULL)
/ogr/ogrsf_frmts/amigocloud/ogramigoclouddatasource.cpp: 418 in OGRAmigoCloudDataSource::RunPOST(const char *, const char *, const char *)()


________________________________________________________________________________________________________
*** CID 1338315:  Null pointer dereferences  (FORWARD_NULL)
/ogr/ogrsf_frmts/amigocloud/ogramigoclouddatasource.cpp: 418 in OGRAmigoCloudDataSource::RunPOST(const char *, const char *, const char *)()
412         }
413         else if (psResult && psResult->nStatus != 0)
414         {
415             CPLDebug( "AMIGOCLOUD", "RunPOST Error Status:%d", psResult->nStatus );
416         }
417     
>>>     CID 1338315:  Null pointer dereferences  (FORWARD_NULL)
>>>     Dereferencing null pointer "psResult".
418         if( psResult->pabyData == NULL )
419         {
420             CPLHTTPDestroyResult(psResult);
421             return NULL;
422         }
423     

** CID 1338314:  Null pointer dereferences  (FORWARD_NULL)
/ogr/ogrsf_frmts/amigocloud/ogramigoclouddatasource.cpp: 512 in OGRAmigoCloudDataSource::RunDELETE(const char *)()


________________________________________________________________________________________________________
*** CID 1338314:  Null pointer dereferences  (FORWARD_NULL)
/ogr/ogrsf_frmts/amigocloud/ogramigoclouddatasource.cpp: 512 in OGRAmigoCloudDataSource::RunDELETE(const char *)()
506         }
507         else if (psResult && psResult->nStatus != 0)
508         {
509             CPLDebug( "AMIGOCLOUD", "RunDELETE Error Status:%d", psResult->nStatus );
510         }
511     
>>>     CID 1338314:  Null pointer dereferences  (FORWARD_NULL)
>>>     Dereferencing null pointer "psResult".
512         if( psResult->pabyData == NULL )
513         {
514             CPLHTTPDestroyResult(psResult);
515             return NULL;
516         }
517     

** CID 1338313:    (RESOURCE_LEAK)
/ogr/ogrsf_frmts/amigocloud/ogramigoclouddatasource.cpp: 407 in OGRAmigoCloudDataSource::RunPOST(const char *, const char *, const char *)()
/ogr/ogrsf_frmts/amigocloud/ogramigoclouddatasource.cpp: 421 in OGRAmigoCloudDataSource::RunPOST(const char *, const char *, const char *)()
/ogr/ogrsf_frmts/amigocloud/ogramigoclouddatasource.cpp: 438 in OGRAmigoCloudDataSource::RunPOST(const char *, const char *, const char *)()
/ogr/ogrsf_frmts/amigocloud/ogramigoclouddatasource.cpp: 469 in OGRAmigoCloudDataSource::RunPOST(const char *, const char *, const char *)()


________________________________________________________________________________________________________
*** CID 1338313:    (RESOURCE_LEAK)
/ogr/ogrsf_frmts/amigocloud/ogramigoclouddatasource.cpp: 407 in OGRAmigoCloudDataSource::RunPOST(const char *, const char *, const char *)()
401             strncmp(psResult->pszContentType, "text/html", 9) == 0)
402         {
403             CPLDebug( "AMIGOCLOUD", "RunPOST HTML Response:%s", psResult->pabyData );
404             CPLError(CE_Failure, CPLE_AppDefined,
405                      "HTML error page returned by server:%s", psResult->pabyData);
406             CPLHTTPDestroyResult(psResult);
>>>     CID 1338313:    (RESOURCE_LEAK)
>>>     Variable "papszOptions" going out of scope leaks the storage it points to.
407             return NULL;
408         }
409         if (psResult && psResult->pszErrBuf != NULL)
410         {
411             CPLDebug( "AMIGOCLOUD", "RunPOST Error Message:%s", psResult->pszErrBuf );
412         }
/ogr/ogrsf_frmts/amigocloud/ogramigoclouddatasource.cpp: 421 in OGRAmigoCloudDataSource::RunPOST(const char *, const char *, const char *)()
415             CPLDebug( "AMIGOCLOUD", "RunPOST Error Status:%d", psResult->nStatus );
416         }
417     
418         if( psResult->pabyData == NULL )
419         {
420             CPLHTTPDestroyResult(psResult);
>>>     CID 1338313:    (RESOURCE_LEAK)
>>>     Variable "papszOptions" going out of scope leaks the storage it points to.
421             return NULL;
422         }
423     
424         CPLDebug( "AMIGOCLOUD", "RunPOST Response:%s", psResult->pabyData );
425     
426         json_tokener* jstok = NULL;
/ogr/ogrsf_frmts/amigocloud/ogramigoclouddatasource.cpp: 438 in OGRAmigoCloudDataSource::RunPOST(const char *, const char *, const char *)()
432         {
433             CPLError( CE_Failure, CPLE_AppDefined,
434                       "JSON parsing error: %s (at offset %d)",
435                       json_tokener_error_desc(jstok->err), jstok->char_offset);
436             json_tokener_free(jstok);
437             CPLHTTPDestroyResult(psResult);
>>>     CID 1338313:    (RESOURCE_LEAK)
>>>     Variable "papszOptions" going out of scope leaks the storage it points to.
438             return NULL;
439         }
440         json_tokener_free(jstok);
441     
442         CPLHTTPDestroyResult(psResult);
443     
/ogr/ogrsf_frmts/amigocloud/ogramigoclouddatasource.cpp: 469 in OGRAmigoCloudDataSource::RunPOST(const char *, const char *, const char *)()
463             {
464                 json_object_put(poObj);
465                 return NULL;
466             }
467         }
468     
>>>     CID 1338313:    (RESOURCE_LEAK)
>>>     Variable "papszOptions" going out of scope leaks the storage it points to.
469         return poObj;
470     }
471     
472     /************************************************************************/
473     /*                               RunDELETE()                               */
474     /************************************************************************/

** CID 1338312:    (RESOURCE_LEAK)
/ogr/ogrsf_frmts/amigocloud/ogramigoclouddatasource.cpp: 501 in OGRAmigoCloudDataSource::RunDELETE(const char *)()
/ogr/ogrsf_frmts/amigocloud/ogramigoclouddatasource.cpp: 515 in OGRAmigoCloudDataSource::RunDELETE(const char *)()
/ogr/ogrsf_frmts/amigocloud/ogramigoclouddatasource.cpp: 532 in OGRAmigoCloudDataSource::RunDELETE(const char *)()
/ogr/ogrsf_frmts/amigocloud/ogramigoclouddatasource.cpp: 563 in OGRAmigoCloudDataSource::RunDELETE(const char *)()


________________________________________________________________________________________________________
*** CID 1338312:    (RESOURCE_LEAK)
/ogr/ogrsf_frmts/amigocloud/ogramigoclouddatasource.cpp: 501 in OGRAmigoCloudDataSource::RunDELETE(const char *)()
495             strncmp(psResult->pszContentType, "text/html", 9) == 0)
496         {
497             CPLDebug( "AMIGOCLOUD", "RunDELETE HTML Response:%s", psResult->pabyData );
498             CPLError(CE_Failure, CPLE_AppDefined,
499                      "HTML error page returned by server:%s", psResult->pabyData);
500             CPLHTTPDestroyResult(psResult);
>>>     CID 1338312:    (RESOURCE_LEAK)
>>>     Variable "papszOptions" going out of scope leaks the storage it points to.
501             return NULL;
502         }
503         if (psResult && psResult->pszErrBuf != NULL)
504         {
505             CPLDebug( "AMIGOCLOUD", "RunDELETE Error Message:%s", psResult->pszErrBuf );
506         }
/ogr/ogrsf_frmts/amigocloud/ogramigoclouddatasource.cpp: 515 in OGRAmigoCloudDataSource::RunDELETE(const char *)()
509             CPLDebug( "AMIGOCLOUD", "RunDELETE Error Status:%d", psResult->nStatus );
510         }
511     
512         if( psResult->pabyData == NULL )
513         {
514             CPLHTTPDestroyResult(psResult);
>>>     CID 1338312:    (RESOURCE_LEAK)
>>>     Variable "papszOptions" going out of scope leaks the storage it points to.
515             return NULL;
516         }
517     
518         CPLDebug( "AMIGOCLOUD", "RunDELETE Response:%s", psResult->pabyData );
519     
520         json_tokener* jstok = NULL;
/ogr/ogrsf_frmts/amigocloud/ogramigoclouddatasource.cpp: 532 in OGRAmigoCloudDataSource::RunDELETE(const char *)()
526         {
527             CPLError( CE_Failure, CPLE_AppDefined,
528                       "JSON parsing error: %s (at offset %d)",
529                       json_tokener_error_desc(jstok->err), jstok->char_offset);
530             json_tokener_free(jstok);
531             CPLHTTPDestroyResult(psResult);
>>>     CID 1338312:    (RESOURCE_LEAK)
>>>     Variable "papszOptions" going out of scope leaks the storage it points to.
532             return NULL;
533         }
534         json_tokener_free(jstok);
535     
536         CPLHTTPDestroyResult(psResult);
537     
/ogr/ogrsf_frmts/amigocloud/ogramigoclouddatasource.cpp: 563 in OGRAmigoCloudDataSource::RunDELETE(const char *)()
557             {
558                 json_object_put(poObj);
559                 return NULL;
560             }
561         }
562     
>>>     CID 1338312:    (RESOURCE_LEAK)
>>>     Variable "papszOptions" going out of scope leaks the storage it points to.
563         return poObj;
564     }
565     
566     /************************************************************************/
567     /*                               RunGET()                               */
568     /************************************************************************/

** CID 1338311:  Resource leaks  (RESOURCE_LEAK)
/ogr/ogrsf_frmts/amigocloud/ogramigoclouddatasource.cpp: 73 in OGRAmigoCloudDataSource::~OGRAmigoCloudDataSource()()


________________________________________________________________________________________________________
*** CID 1338311:  Resource leaks  (RESOURCE_LEAK)
/ogr/ogrsf_frmts/amigocloud/ogramigoclouddatasource.cpp: 73 in OGRAmigoCloudDataSource::~OGRAmigoCloudDataSource()()
67         CPLFree( papoLayers );
68     
69         if (bMustCleanPersistant)
70         {
71             char** papszOptions = NULL;
72             papszOptions = CSLSetNameValue(papszOptions, "CLOSE_PERSISTENT", CPLSPrintf("AMIGOCLOUD:%p", this));
>>>     CID 1338311:  Resource leaks  (RESOURCE_LEAK)
>>>     Ignoring storage allocated by "CPLHTTPFetch(this->GetAPIURL(), papszOptions)" leaks it.
73             CPLHTTPFetch( GetAPIURL(), papszOptions);
74             CSLDestroy(papszOptions);
75         }
76     
77         CPLFree( pszName );
78         CPLFree(pszProjetctId);

Change History (1)

comment:1 by Even Rouault, 8 years ago

Resolution: fixed
Status: newclosed

Fixed by r31916 "Amigocloud: fix memleaks and warning about null pointer dereference (CID 1338311 to 1338315)"

Note: See TracTickets for help on using tickets.