ref: 75f9b7ee3f5dba224c6c73e9808e2517e6429c7b
parent: 153f833ce7f000999a73c02be290f81df9dd738b
parent: bbf97cddaba6ac97a9445546ca133f3b1b719cc2
author: huili2 <huili2@cisco.com>
date: Fri Dec 29 08:22:38 EST 2017
Merge pull request #2893 from GuangweiWang/fix-issue-external bugfix: reference before NULL check
--- a/codec/console/dec/src/h264dec.cpp
+++ b/codec/console/dec/src/h264dec.cpp
@@ -78,13 +78,10 @@
FILE* pOptionFile = NULL;
// Lenght input mode support
FILE* fpTrack = NULL;
- if (pLengthFileName != NULL) {
- fpTrack = fopen (pLengthFileName, "rb");
- if (fpTrack == NULL)
- printf ("Length file open ERROR!\n");
- }
- int32_t pInfo[4];
+ if (pDecoder == NULL) return;
+
+ int32_t pInfo[4];
unsigned long long uiTimeStamp = 0;
int64_t iStart = 0, iEnd = 0, iTotal = 0;
int32_t iSliceSize;
@@ -109,7 +106,6 @@
CUtils cOutputModule;
double dElapsed = 0;
- if (pDecoder == NULL) return;
if (kpH264FileName) {
pH264File = fopen (kpH264FileName, "rb");
if (pH264File == NULL) {
@@ -144,6 +140,12 @@
fprintf (stderr, "Extra optional file: %s..\n", pOptionFileName);
}
+ if (pLengthFileName != NULL) {
+ fpTrack = fopen (pLengthFileName, "rb");
+ if (fpTrack == NULL)
+ printf ("Length file open ERROR!\n");
+ }
+
printf ("------------------------------------------------------\n");
fseek (pH264File, 0L, SEEK_END);
@@ -178,7 +180,7 @@
// Read length from file if needed
if (fpTrack) {
if (fread (pInfo, 4, sizeof (int32_t), fpTrack) < 4)
- return;
+ goto label_exit;
iSliceSize = static_cast<int32_t> (pInfo[2]);
} else {
for (i = 0; i < iFileSize; i++) {
@@ -284,11 +286,6 @@
++ iSliceIndex;
}
- if (fpTrack) {
- fclose (fpTrack);
- fpTrack = NULL;
- }
-
dElapsed = iTotal / 1e6;
fprintf (stderr, "-------------------------------------------------------\n");
fprintf (stderr, "iWidth:\t\t%d\nheight:\t\t%d\nFrames:\t\t%d\ndecode time:\t%f sec\nFPS:\t\t%f fps\n",
@@ -319,6 +316,11 @@
fclose (pOptionFile);
pOptionFile = NULL;
}
+ if (fpTrack) {
+ fclose (fpTrack);
+ fpTrack = NULL;
+ }
+
}
#if (defined(ANDROID_NDK)||defined(APPLE_IOS) || defined (WINDOWS_PHONE))