Fossil

Check-in [92221aaa]
Login

Check-in [92221aaa]

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Fix a misuse of an unsigned integer in the blobReallocMalloc() which can lead to redundant memory reallocations.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | markdown-footnotes
Files: files | file ages | folders
SHA3-256: 92221aaa192e82e89263e109098bd9bcda9ecf1128ae6f79b742321eada8793a
User & Date: george 2022-02-09 19:38:37
References
2022-02-09
20:23
Cherrypicked [92221aaa192e82] and [7283ae6e120c10] on behalf of George. ... (check-in: f902814d user: stephan tags: trunk)
Context
2022-02-09
20:23
Cherrypicked [92221aaa192e82] and [7283ae6e120c10] on behalf of George. ... (check-in: f902814d user: stephan tags: trunk)
20:09
Join duplicated footnotes slightly faster. Fix a comment about auxiliary cmp_footnote_id() function. ... (check-in: 7f6a6418 user: george tags: markdown-footnotes)
19:38
Fix a misuse of an unsigned integer in the blobReallocMalloc() which can lead to redundant memory reallocations. ... (check-in: 92221aaa user: george tags: markdown-footnotes)
19:29
Fix a bug in the blob_reserve() function that was introduced by [1243bf39996b8a]. The current mainline is not affected because this function is not used anywhere. However it was causing memory corruption on the 'markdown-footnotes' branch since it was employed in [544df852b2d9a1]. ... (check-in: 7283ae6e user: george tags: markdown-footnotes)
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/blob.c.

162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
  if( newSize==0 ){
    free(pBlob->aData);
    pBlob->aData = 0;
    pBlob->nAlloc = 0;
    pBlob->nUsed = 0;
    pBlob->iCursor = 0;
    pBlob->blobFlags = 0;
  }else if( newSize>pBlob->nAlloc || newSize<pBlob->nAlloc-4000 ){
    char *pNew = fossil_realloc(pBlob->aData, newSize);
    pBlob->aData = pNew;
    pBlob->nAlloc = newSize;
    if( pBlob->nUsed>pBlob->nAlloc ){
      pBlob->nUsed = pBlob->nAlloc;
    }
  }







|







162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
  if( newSize==0 ){
    free(pBlob->aData);
    pBlob->aData = 0;
    pBlob->nAlloc = 0;
    pBlob->nUsed = 0;
    pBlob->iCursor = 0;
    pBlob->blobFlags = 0;
  }else if( newSize>pBlob->nAlloc || newSize+4000<pBlob->nAlloc ){
    char *pNew = fossil_realloc(pBlob->aData, newSize);
    pBlob->aData = pNew;
    pBlob->nAlloc = newSize;
    if( pBlob->nUsed>pBlob->nAlloc ){
      pBlob->nUsed = pBlob->nAlloc;
    }
  }